Skip to content

Commit 38e3896

Browse files
tacaswellMeeseeksDev[bot]
authored and
MeeseeksDev[bot]
committed
Backport PR #11692: Deprecate frameon kwarg and rcParam to savefig.
1 parent d41b367 commit 38e3896

File tree

6 files changed

+16
-11
lines changed

6 files changed

+16
-11
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Deprecations
2+
````````````
3+
4+
The ``frameon`` kwarg to ``savefig`` and the ``savefig.frameon`` rcParam
5+
are deprecated. To emulate ``frameon = False``, set ``facecolor`` to fully
6+
transparent (``"none"``, or ``(0, 0, 0, 0)``).

lib/matplotlib/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,7 @@ def gen_candidates():
704704
# Values are tuples of (version,)
705705
_deprecated_remain_as_none = {
706706
'text.latex.unicode': ('3.0',),
707+
'savefig.frameon': ('3.1',),
707708
}
708709

709710

lib/matplotlib/figure.py

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

2035-
def savefig(self, fname, *, frameon=None, transparent=None, **kwargs):
2035+
def savefig(self, fname, *, transparent=None, **kwargs):
20362036
"""
20372037
Save the current figure.
20382038
@@ -2114,11 +2114,6 @@ def savefig(self, fname, *, frameon=None, transparent=None, **kwargs):
21142114
transparency of these patches will be restored to their
21152115
original values upon exit of this function.
21162116
2117-
frameon : bool
2118-
If *True*, the figure patch will be colored, if *False*, the
2119-
figure background will be transparent. If not provided, the
2120-
rcParam 'savefig.frameon' will be used.
2121-
21222117
bbox_inches : str or `~matplotlib.transforms.Bbox`, optional
21232118
Bbox in inches. Only the given portion of the figure is
21242119
saved. If 'tight', try to figure out the tight bbox of
@@ -2150,8 +2145,14 @@ def savefig(self, fname, *, frameon=None, transparent=None, **kwargs):
21502145
"""
21512146

21522147
kwargs.setdefault('dpi', rcParams['savefig.dpi'])
2153-
if frameon is None:
2154-
frameon = rcParams['savefig.frameon']
2148+
if "frameon" in kwargs:
2149+
cbook.warn_deprecated("3.1", name="frameon", obj_type="kwarg",
2150+
alternative="facecolor")
2151+
frameon = kwargs.pop("frameon")
2152+
if frameon is None:
2153+
frameon = dict.__getitem__(rcParams, 'savefig.frameon')
2154+
else:
2155+
frameon = False # Won't pass "if frameon:" below.
21552156
if transparent is None:
21562157
transparent = rcParams['savefig.transparent']
21572158

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
@@ -540,7 +540,6 @@
540540
## leave empty to always use current working directory
541541
#savefig.transparent : False ## setting that controls whether figures are saved with a
542542
## transparent background by default
543-
#savefig.frameon : True ## enable frame of figure when saving
544543
#savefig.orientation : portrait ## Orientation of saved figure
545544

546545
### tk backend params

0 commit comments

Comments
 (0)