[Bug]: `rcdefaults` and `rcParams.clear()` don't work? · Issue #25855 · matplotlib/matplotlib · GitHub
Skip to content

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

Description

@chahak13

Bug summary

This is the rcdefaults() function

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 in STYLE_BLACKLIST then there are 2 problems I think:

  1. rcParams.clear() doesn't work. It doesn't clear out the entire dictionary.
  2. After the update line, rcParams will still have keys from STYLE_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 from STYLE_BLACKLIST but then I'm not sure why clear() 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]: 8988

In [4]: mpl.rcParams["webagg.port"] = 9000

In [5]: mpl.rcParams["webagg.port"]
Out[5]: 9000

In [6]: mpl.rcdefaults()

In [7]: mpl.rcParams["webagg.port"]
Out[7]: 9000

In [8]: mpl.rcParams.clear()

In [9]: mpl.rcParams["webagg.port"]
Out[9]: 9000

Actual outcome

clear() doesn't empty the rcParams dictionary.

Expected outcome

clear() should empty the dictionary and after rcdefaults(), keys from STYLE_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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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