From 38e389690e90c3e7f42c99e6faf027b9a2972b85 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Mon, 11 Mar 2019 16:19:55 -0400 Subject: [PATCH] Backport PR #11692: Deprecate frameon kwarg and rcParam to savefig. --- doc/api/next_api_changes/2018-09-25-AL.rst | 6 ++++++ lib/matplotlib/__init__.py | 1 + lib/matplotlib/figure.py | 17 +++++++++-------- .../mpl-data/stylelib/_classic_test.mplstyle | 1 - .../mpl-data/stylelib/classic.mplstyle | 1 - matplotlibrc.template | 1 - 6 files changed, 16 insertions(+), 11 deletions(-) create mode 100644 doc/api/next_api_changes/2018-09-25-AL.rst diff --git a/doc/api/next_api_changes/2018-09-25-AL.rst b/doc/api/next_api_changes/2018-09-25-AL.rst new file mode 100644 index 000000000000..75edb07c024d --- /dev/null +++ b/doc/api/next_api_changes/2018-09-25-AL.rst @@ -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)``). diff --git a/lib/matplotlib/__init__.py b/lib/matplotlib/__init__.py index 489756d9f57a..bc1f0d999331 100644 --- a/lib/matplotlib/__init__.py +++ b/lib/matplotlib/__init__.py @@ -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',), } diff --git a/lib/matplotlib/figure.py b/lib/matplotlib/figure.py index b22b2356150e..db809e71d96b 100644 --- a/lib/matplotlib/figure.py +++ b/lib/matplotlib/figure.py @@ -2032,7 +2032,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. @@ -2114,11 +2114,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 @@ -2150,8 +2145,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'] diff --git a/lib/matplotlib/mpl-data/stylelib/_classic_test.mplstyle b/lib/matplotlib/mpl-data/stylelib/_classic_test.mplstyle index b6807990e764..5ae7b7a39e56 100644 --- a/lib/matplotlib/mpl-data/stylelib/_classic_test.mplstyle +++ b/lib/matplotlib/mpl-data/stylelib/_classic_test.mplstyle @@ -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 diff --git a/lib/matplotlib/mpl-data/stylelib/classic.mplstyle b/lib/matplotlib/mpl-data/stylelib/classic.mplstyle index 48f5a4521991..f52170541c81 100644 --- a/lib/matplotlib/mpl-data/stylelib/classic.mplstyle +++ b/lib/matplotlib/mpl-data/stylelib/classic.mplstyle @@ -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 diff --git a/matplotlibrc.template b/matplotlibrc.template index df9ed2c7bcfc..c06ec1f8f9c3 100644 --- a/matplotlibrc.template +++ b/matplotlibrc.template @@ -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 pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy