Skip to content

Commit b69f8e6

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 8d66b47 commit b69f8e6

File tree

6 files changed

+17
-12
lines changed

6 files changed

+17
-12
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),

lib/matplotlib/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -758,10 +758,10 @@ def gen_candidates():
758758
# listed in the rcParams (not included in _all_deprecated).
759759
# Values are tuples of (version,)
760760
_deprecated_remain_as_none = {
761-
'axes.hold': ('2.1',),
762761
'backend.qt4': ('2.2',),
763762
'backend.qt5': ('2.2',),
764763
'text.latex.unicode': ('3.0',),
764+
'savefig.frameon': ('3.1',),
765765
}
766766

767767

lib/matplotlib/figure.py

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

1978-
def savefig(self, fname, *, frameon=None, transparent=None, **kwargs):
1978+
def savefig(self, fname, *, transparent=None, **kwargs):
19791979
"""
19801980
Save the current figure.
19811981
@@ -2057,11 +2057,6 @@ def savefig(self, fname, *, frameon=None, transparent=None, **kwargs):
20572057
transparency of these patches will be restored to their
20582058
original values upon exit of this function.
20592059
2060-
frameon : bool
2061-
If *True*, the figure patch will be colored, if *False*, the
2062-
figure background will be transparent. If not provided, the
2063-
rcParam 'savefig.frameon' will be used.
2064-
20652060
bbox_inches : str or `~matplotlib.transforms.Bbox`, optional
20662061
Bbox in inches. Only the given portion of the figure is
20672062
saved. If 'tight', try to figure out the tight bbox of
@@ -2087,8 +2082,14 @@ def savefig(self, fname, *, frameon=None, transparent=None, **kwargs):
20872082
20882083
"""
20892084
kwargs.setdefault('dpi', rcParams['savefig.dpi'])
2090-
if frameon is None:
2091-
frameon = rcParams['savefig.frameon']
2085+
if "frameon" in kwargs:
2086+
cbook.warn_deprecated("3.1", name="frameon", obj_type="kwarg",
2087+
alternative="facecolor")
2088+
frameon = kwargs.pop("frameon")
2089+
if frameon is None:
2090+
frameon = dict.__getitem__(rcParams, 'savefig.frameon')
2091+
else:
2092+
frameon = False # Won't pass "if frameon:" below.
20922093
if transparent is None:
20932094
transparent = rcParams['savefig.transparent']
20942095

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
@@ -533,7 +533,6 @@
533533
## leave empty to always use current working directory
534534
#savefig.transparent : False ## setting that controls whether figures are saved with a
535535
## transparent background by default
536-
#savefig.frameon : True ## enable frame of figure when saving
537536
#savefig.orientation : portrait ## Orientation of saved figure
538537

539538
### tk backend params

0 commit comments

Comments
 (0)