Skip to content

Deprecate frameon kwarg and rcParam to savefig. #11692

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions doc/api/next_api_changes/2018-09-25-AL.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Deprecations
````````````

The ``frameon`` kwarg to ``savefig`` and the ``savefig.frameon`` rcParam
are deprecated. To emulate ``frameon = False``, set ``facecolor`` to fully
transparent (``"none"``, or ``(0, 0, 0, 0)``).
1 change: 1 addition & 0 deletions lib/matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,7 @@ def gen_candidates():
# Values are tuples of (version,)
_deprecated_remain_as_none = {
'text.latex.unicode': ('3.0',),
'savefig.frameon': ('3.1',),
}


Expand Down
17 changes: 9 additions & 8 deletions lib/matplotlib/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -2020,7 +2020,7 @@ def add_axobserver(self, func):
"""Whenever the axes state change, ``func(self)`` will be called."""
self._axobservers.append(func)

def savefig(self, fname, *, frameon=None, transparent=None, **kwargs):
def savefig(self, fname, *, transparent=None, **kwargs):
"""
Save the current figure.

Expand Down Expand Up @@ -2102,11 +2102,6 @@ def savefig(self, fname, *, frameon=None, transparent=None, **kwargs):
transparency of these patches will be restored to their
original values upon exit of this function.

frameon : bool
If *True*, the figure patch will be colored, if *False*, the
figure background will be transparent. If not provided, the
rcParam 'savefig.frameon' will be used.

bbox_inches : str or `~matplotlib.transforms.Bbox`, optional
Bbox in inches. Only the given portion of the figure is
saved. If 'tight', try to figure out the tight bbox of
Expand Down Expand Up @@ -2138,8 +2133,14 @@ def savefig(self, fname, *, frameon=None, transparent=None, **kwargs):
"""

kwargs.setdefault('dpi', rcParams['savefig.dpi'])
if frameon is None:
frameon = rcParams['savefig.frameon']
if "frameon" in kwargs:
cbook.warn_deprecated("3.1", name="frameon", obj_type="kwarg",
alternative="facecolor")
frameon = kwargs.pop("frameon")
if frameon is None:
frameon = dict.__getitem__(rcParams, 'savefig.frameon')
else:
frameon = False # Won't pass "if frameon:" below.
if transparent is None:
transparent = rcParams['savefig.transparent']

Expand Down
1 change: 0 additions & 1 deletion lib/matplotlib/mpl-data/stylelib/_classic_test.mplstyle
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,6 @@ savefig.pad_inches : 0.1 # Padding to be used when bbox is set to 'tight'
savefig.jpeg_quality: 95 # when a jpeg is saved, the default quality parameter.
savefig.transparent : False # setting that controls whether figures are saved with a
# transparent background by default
savefig.frameon : True
savefig.orientation : portrait

# ps backend params
Expand Down
1 change: 0 additions & 1 deletion lib/matplotlib/mpl-data/stylelib/classic.mplstyle
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,6 @@ savefig.pad_inches : 0.1 # Padding to be used when bbox is set to 'tight'
savefig.jpeg_quality: 95 # when a jpeg is saved, the default quality parameter.
savefig.transparent : False # setting that controls whether figures are saved with a
# transparent background by default
savefig.frameon : True
savefig.orientation : portrait

# ps backend params
Expand Down
1 change: 0 additions & 1 deletion matplotlibrc.template
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,6 @@
## leave empty to always use current working directory
#savefig.transparent : False ## setting that controls whether figures are saved with a
## transparent background by default
#savefig.frameon : True ## enable frame of figure when saving
#savefig.orientation : portrait ## Orientation of saved figure

### tk backend params
Expand Down