Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Bug]:rcdefaults andrcParams.clear() don't work? #25855

Open
@chahak13

Description

@chahak13

Bug summary

This is thercdefaults() function

defrcdefaults():
"""
Restore the `.rcParams` from Matplotlib's internal default style.
Style-blacklisted `.rcParams` (defined in
``matplotlib.style.core.STYLE_BLACKLIST``) are not updated.
See Also
--------
matplotlib.rc_file_defaults
Restore the `.rcParams` from the rc file originally loaded by
Matplotlib.
matplotlib.style.use
Use a specific style file. Call ``style.use('default')`` to restore
the default style.
"""
# Deprecation warnings were already handled when creating rcParamsDefault,
# no need to reemit them here.
with_api.suppress_matplotlib_deprecation_warning():
from .style.coreimportSTYLE_BLACKLIST
rcParams.clear()
rcParams.update({k:vfork,vinrcParamsDefault.items()
ifknotinSTYLE_BLACKLIST})

What exactly are we trying to do here? According to the docstring, if we're trying to reset the rcParams dictionary and only reset the keys that are not inSTYLE_BLACKLIST then there are 2 problems I think:

  1. rcParams.clear() doesn't work. It doesn't clear out the entire dictionary.
  2. After theupdate line,rcParams will still have keys fromSTYLE_BLACKLIST which, if I were to perform the same operations on a dictionary, shouldn't be the case.
  3. While it does make sense to still have the keys fromSTYLE_BLACKLIST but then I'm not sure whyclear() is used and not just directly update the keys.

Also, sidenote,popitem() errors out without a good error message (which is also why clear doesn't actually empty the dict?)

Code for reproduction

In [3]:mpl.rcParams["webagg.port"]Out[3]:8988In [4]:mpl.rcParams["webagg.port"]=9000In [5]:mpl.rcParams["webagg.port"]Out[5]:9000In [6]:mpl.rcdefaults()In [7]:mpl.rcParams["webagg.port"]Out[7]:9000In [8]:mpl.rcParams.clear()In [9]:mpl.rcParams["webagg.port"]Out[9]:9000

Actual outcome

clear() doesn't empty thercParams dictionary.

Expected outcome

clear() should empty the dictionary and afterrcdefaults(), keys fromSTYLE_BLACKLIST shouldn't be there.

Additional information

I'm not sure if this is a documentation issue and the behaviour is intended or the behaviour isn't intended.

Operating system

No response

Matplotlib Version

Current main

Matplotlib Backend

No response

Python version

No response

Jupyter version

No response

Installation

None

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp