Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 60f998b

Browse filesBrowse files
author
patchen
committed
Moved new dpi option to Figure.savefig()
1 parent f6329f8 commit 60f998b
Copy full SHA for 60f998b

File tree

Expand file treeCollapse file tree

2 files changed

+5
-5
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+5
-5
lines changed

‎lib/matplotlib/backend_bases.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backend_bases.py
-3Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2084,7 +2084,6 @@ def print_figure(self, filename, dpi=None, facecolor='w', edgecolor='w',
20842084
20852085
*dpi*
20862086
the dots per inch to save the figure in; if None, use savefig.dpi
2087-
if 'native' use dpi from figure
20882087
20892088
*facecolor*
20902089
the facecolor of the figure
@@ -2128,8 +2127,6 @@ def print_figure(self, filename, dpi=None, facecolor='w', edgecolor='w',
21282127

21292128
if dpi is None:
21302129
dpi = rcParams['savefig.dpi']
2131-
elif dpi == 'native':
2132-
dpi = self.figure.dpi
21332130

21342131
origDPI = self.figure.dpi
21352132
origfacecolor = self.figure.get_facecolor()

‎lib/matplotlib/figure.py

Copy file name to clipboardExpand all lines: lib/matplotlib/figure.py
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1424,9 +1424,10 @@ def savefig(self, *args, **kwargs):
14241424
14251425
Keyword arguments:
14261426
1427-
*dpi*: [ *None* | ``scalar > 0`` ]
1427+
*dpi*: [ *None* | ``scalar > 0`` | 'figure']
14281428
The resolution in dots per inch. If *None* it will default to
1429-
the value ``savefig.dpi`` in the matplotlibrc file.
1429+
the value ``savefig.dpi`` in the matplotlibrc file. If 'figure'
1430+
it will set the dpi to be the value of the figure.
14301431
14311432
*facecolor*, *edgecolor*:
14321433
the colors of the figure rectangle
@@ -1473,6 +1474,8 @@ def savefig(self, *args, **kwargs):
14731474
"""
14741475

14751476
kwargs.setdefault('dpi', rcParams['savefig.dpi'])
1477+
if kwargs['dpi'] == 'figure':
1478+
kwargs['dpi'] = self.get_dpi()
14761479
frameon = kwargs.pop('frameon', rcParams['savefig.frameon'])
14771480
transparent = kwargs.pop('transparent',
14781481
rcParams['savefig.transparent'])

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.