Description
Bug summary
This is the rcdefaults()
function
matplotlib/lib/matplotlib/__init__.py
Lines 1068 to 1091 in 8faa835
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:
rcParams.clear()
doesn't work. It doesn't clear out the entire dictionary.- After the
update
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. - While it does make sense to still have the keys from
STYLE_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]: 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