Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Description
Bug summary
This is thercdefaults()
function
matplotlib/lib/matplotlib/__init__.py
Lines 1068 to 1091 in8faa835
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:
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]: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