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 8a3a4df

Browse filesBrowse files
committed
Merge pull request #2390 from tacaswell/transparent_rcparams
Transparent rcparams
2 parents b7f7ddd + 6c3cd20 commit 8a3a4df
Copy full SHA for 8a3a4df

File tree

6 files changed

+19
-2
lines changed
Filter options

6 files changed

+19
-2
lines changed

‎doc/api/api_changes.rst

Copy file name to clipboardExpand all lines: doc/api/api_changes.rst
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ original location:
5959
thus `colorbar.ColorbarBase.outline` is now a
6060
`matplotlib.patches.Polygon` object.
6161

62+
* The rcParams `savefig.transparent` has been added to control
63+
default transparency when saving figures.
64+
6265
.. _changes_in_1_3:
6366

6467

‎doc/users/whats_new.rst

Copy file name to clipboardExpand all lines: doc/users/whats_new.rst
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@ and :func:`matplotlib.dates.datestr2num`. Support is also added to the unit
4444
conversion interfaces :class:`matplotlib.dates.DateConverter` and
4545
:class:`matplotlib.units.Registry`.
4646

47+
Configuration (rcParams)
48+
------------------------
49+
50+
``savefig.transparent`` added
51+
`````````````````````````````
52+
Controls whether figures are saved with a transparent
53+
background by default. Previously `savefig` always defaulted
54+
to a non-transparent background.
55+
4756
.. _whats-new-1-3:
4857

4958
new in matplotlib-1.3

‎lib/matplotlib/figure.py

Copy file name to clipboardExpand all lines: lib/matplotlib/figure.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1414,7 +1414,7 @@ def savefig(self, *args, **kwargs):
14141414

14151415
kwargs.setdefault('dpi', rcParams['savefig.dpi'])
14161416
frameon = kwargs.pop('frameon', rcParams['savefig.frameon'])
1417-
transparent = kwargs.pop('transparent', False)
1417+
transparent = kwargs.pop('transparent', rcParams['savefig.transparent'])
14181418

14191419
if transparent:
14201420
kwargs.setdefault('facecolor', 'none')

‎lib/matplotlib/pyplot.py

Copy file name to clipboardExpand all lines: lib/matplotlib/pyplot.py
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,9 @@ def draw():
563563
@docstring.copy_dedent(Figure.savefig)
564564
def savefig(*args, **kwargs):
565565
fig = gcf()
566-
return fig.savefig(*args, **kwargs)
566+
res = fig.savefig(*args, **kwargs)
567+
draw() # need this if 'transparent=True' to reset colors
568+
return res
567569

568570

569571
@docstring.copy_dedent(Figure.ginput)

‎lib/matplotlib/rcsetup.py

Copy file name to clipboardExpand all lines: lib/matplotlib/rcsetup.py
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,7 @@ def __call__(self, s):
714714
'savefig.pad_inches': [0.1, validate_float],
715715
# default directory in savefig dialog box
716716
'savefig.directory': ['~', six.text_type],
717+
'savefig.transparent': [False, validate_bool],
717718

718719
# Maintain shell focus for TkAgg
719720
'tk.window_focus': [False, validate_bool],

‎matplotlibrc.template

Copy file name to clipboardExpand all lines: matplotlibrc.template
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,8 @@ backend : %(backend)s
377377
#savefig.jpeg_quality: 95 # when a jpeg is saved, the default quality parameter.
378378
#savefig.directory : ~ # default directory in savefig dialog box,
379379
# leave empty to always use current working directory
380+
#savefig.transparent : False # setting that controls whether figures are saved with a
381+
# transparent background by default
380382

381383
# tk backend params
382384
#tk.window_focus : False # Maintain shell focus for TkAgg

0 commit comments

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