Skip to content

Commit 57269b9

Browse files
committed
Deprecate frameon kwarg and rcParam to savefig.
``frameon = False`` has *never* worked since its introduction in 2013 due to the buggy implementation that only took it into account if True: if frameon: original_frameon = self.get_frameon() self.set_frameon(frameon) (despite the doc stating otherwise). One can also set the facecolor kwarg or savefig.facecolor rcParam to fully transparent for the same effect.
1 parent 4769f7b commit 57269b9

File tree

7 files changed

+24
-18
lines changed

7 files changed

+24
-18
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Deprecations
2+
````````````
3+
4+
The following API elements are deprecated:
5+
6+
- the ``frameon`` kwarg to ``savefig`` and the ``savefig.frameon`` rcParam (use
7+
``facecolor`` instead),

doc/users/whats_new.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@ revision, see the :ref:`github-stats`.
1515
For a release, add a new section after this, then comment out the include
1616
and toctree below by indenting them. Uncomment them after the release.
1717
18-
.. include:: next_whats_new/README.rst
19-
.. toctree::
20-
:glob:
21-
:maxdepth: 1
18+
.. include:: next_whats_new/README.rst
2219

23-
next_whats_new/*
20+
.. toctree::
21+
:glob:
22+
:maxdepth: 1
23+
24+
next_whats_new/*
2425

2526
Ability to scale axis by a fixed order of magnitude
2627
---------------------------------------------------

lib/matplotlib/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -787,12 +787,12 @@ def gen_candidates():
787787

788788
# rcParams deprecated; can use None to suppress warnings; remain actually
789789
# listed in the rcParams (not included in _all_deprecated).
790-
# Values are typles of (version,)
790+
# Values are tuples of (version,)
791791
_deprecated_remain_as_none = {
792-
'axes.hold': ('2.1',),
793792
'backend.qt4': ('2.2',),
794793
'backend.qt5': ('2.2',),
795794
'text.latex.unicode': ('3.0',),
795+
'savefig.frameon': ('3.1',),
796796
}
797797

798798

lib/matplotlib/figure.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1934,7 +1934,7 @@ def add_axobserver(self, func):
19341934
"""Whenever the axes state change, ``func(self)`` will be called."""
19351935
self._axobservers.append(func)
19361936

1937-
def savefig(self, fname, *, frameon=None, transparent=None, **kwargs):
1937+
def savefig(self, fname, *, transparent=None, **kwargs):
19381938
"""
19391939
Save the current figure.
19401940
@@ -2005,11 +2005,6 @@ def savefig(self, fname, *, frameon=None, transparent=None, **kwargs):
20052005
transparency of these patches will be restored to their
20062006
original values upon exit of this function.
20072007
2008-
frameon : bool
2009-
If *True*, the figure patch will be colored, if *False*, the
2010-
figure background will be transparent. If not provided, the
2011-
rcParam 'savefig.frameon' will be used.
2012-
20132008
bbox_inches : str or `~matplotlib.transforms.Bbox`, optional
20142009
Bbox in inches. Only the given portion of the figure is
20152010
saved. If 'tight', try to figure out the tight bbox of
@@ -2025,8 +2020,14 @@ def savefig(self, fname, *, frameon=None, transparent=None, **kwargs):
20252020
20262021
"""
20272022
kwargs.setdefault('dpi', rcParams['savefig.dpi'])
2028-
if frameon is None:
2029-
frameon = rcParams['savefig.frameon']
2023+
if "frameon" in kwargs:
2024+
cbook.warn_deprecated("3.1", name="frameon", obj_type="kwarg",
2025+
alternative="facecolor")
2026+
frameon = kwargs.pop("frameon")
2027+
if frameon is None:
2028+
frameon = dict.__getitem__(rcParams, 'savefig.frameon')
2029+
else:
2030+
frameon = False # Won't pass "if frameon:" below.
20302031
if transparent is None:
20312032
transparent = rcParams['savefig.transparent']
20322033

lib/matplotlib/mpl-data/stylelib/_classic_test.mplstyle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,6 @@ savefig.pad_inches : 0.1 # Padding to be used when bbox is set to 'tight'
418418
savefig.jpeg_quality: 95 # when a jpeg is saved, the default quality parameter.
419419
savefig.transparent : False # setting that controls whether figures are saved with a
420420
# transparent background by default
421-
savefig.frameon : True
422421
savefig.orientation : portrait
423422

424423
# ps backend params

lib/matplotlib/mpl-data/stylelib/classic.mplstyle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,6 @@ savefig.pad_inches : 0.1 # Padding to be used when bbox is set to 'tight'
422422
savefig.jpeg_quality: 95 # when a jpeg is saved, the default quality parameter.
423423
savefig.transparent : False # setting that controls whether figures are saved with a
424424
# transparent background by default
425-
savefig.frameon : True
426425
savefig.orientation : portrait
427426

428427
# ps backend params

matplotlibrc.template

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,6 @@ backend : $TEMPLATE_BACKEND
532532
## leave empty to always use current working directory
533533
#savefig.transparent : False ## setting that controls whether figures are saved with a
534534
## transparent background by default
535-
#savefig.frameon : True ## enable frame of figure when saving
536535
#savefig.orientation : portrait ## Orientation of saved figure
537536

538537
### tk backend params

0 commit comments

Comments
 (0)