8000 Don't update style-blacklisted rcparams in rc_* functions by anntzer · Pull Request #9150 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Don't update style-blacklisted rcparams in rc_* functions #9150

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
Jul 15, 2018
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
Don't update style-blacklisted rcparams in rc_* functions.
This avoids incorrectly updating e.g. the ``backend`` or ``interactive``
rcParams.
  • Loading branch information
anntzer committed Jul 12, 2018
commit 30d764b6f444a7fadaed5226e6a05222e4abb4cd
7 changes: 7 additions & 0 deletions doc/api/api_changes/2017-09-02-AL-rc-blacklist.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Blacklisted rcparams no longer updated by `rcdefaults`, `rc_file_defaults`, `rc_file`
-------------------------------------------------------------------------------------

The rc modifier functions `rcdefaults`, `rc_file_defaults` and `rc_file`
now ignore rcParams in the `matplotlib.style.core.STYLE_BLACKLIST` set. In
particular, this prevents the ``backend`` and ``interactive`` rcParams from
being incorrectly modified by these functions.
27 changes: 22 additions & 5 deletions lib/matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1205,7 +1205,11 @@ def rc(group, **kwargs):


def rcdefaults():
"""Restore the rc params from Matplotlib's internal defaults.
"""
Restore the rc params from Matplotlib's internal default style.

Style-blacklisted rc params (defined in
`matplotlib.style.core.STYLE_BLACKLIST`) are not updated.

See Also
--------
Expand All @@ -1219,29 +1223,42 @@ def rcdefaults():
# no need to reemit them here.
with warnings.catch_warnings():
warnings.simplefilter("ignore", mplDeprecation)
from .style.core import STYLE_BLACKLIST
rcParams.clear()
rcParams.update(rcParamsDefault)
rcParams.update({k: v for k, v in rcParamsDefault.items()
if k not in STYLE_BLACKLIST})


def rc_file_defaults():
"""Restore the rc params from the original rc file loaded by Matplotlib.
"""
Restore the rc params from the original rc file loaded by Matplotlib.

Style-blacklisted rc params (defined in
`matplotlib.style.core.STYLE_BLACKLIST`) are not updated.
"""
# Deprecation warnings were already handled when creating rcParamsOrig, no
# need to reemit them here.
with warnings.catch_warnings():
warnings.simplefilter("ignore", mplDeprecation)
rcParams.update(rcParamsOrig)
from .style.core import STYLE_BLACKLIST
rcParams.update({k: v for k, v in rcParamsOrig.items()
if k not in STYLE_BLACKLIST})


def rc_file(fname):
"""
Update rc params from file.

Style-blacklisted rc params (defined in
`matplotlib.style.core.STYLE_BLACKLIST`) are not updated.
"""
# Deprecation warnings were already handled in rc_params_from_file, no need
# to reemit them here.
with warnings.catch_warnings():
warnings.simplefilter("ignore", mplDeprecation)
rcParams.update(rc_params_from_file(fname))
from .style.core import STYLE_BLACKLIST
rcParams.update({k: v for k, v in rc_params_from_file(fname).items()
if k not in STYLE_BLACKLIST})


class rc_context:
Expand Down
0