Title: [Bug]: `rcdefaults` and `rcParams.clear()` don't work? · Issue #25855 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: `rcdefaults` and `rcParams.clear()` don't work? · Issue #25855 · matplotlib/matplotlib
X Title: [Bug]: `rcdefaults` and `rcParams.clear()` don't work? · Issue #25855 · matplotlib/matplotlib
Description: Bug summary This is the rcdefaults() function matplotlib/lib/matplotlib/__init__.py Lines 1068 to 1091 in 8faa835 def rcdefaults(): """ Restore the `.rcParams` from Matplotlib's internal default style. Style-blacklisted `.rcParams` (defi...
Open Graph Description: Bug summary This is the rcdefaults() function matplotlib/lib/matplotlib/__init__.py Lines 1068 to 1091 in 8faa835 def rcdefaults(): """ Restore the `.rcParams` from Matplotlib's internal default st...
X Description: Bug summary This is the rcdefaults() function matplotlib/lib/matplotlib/__init__.py Lines 1068 to 1091 in 8faa835 def rcdefaults(): """ Restore the `.rcParams` from Matplotlib's ...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/25855
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: `rcdefaults` and `rcParams.clear()` don't work? ","articleBody":"### Bug summary\n\nThis is the `rcdefaults()` function\r\nhttps://github.com/matplotlib/matplotlib/blob/8faa835c81d9cf12342992521ddb95e9a645bc36/lib/matplotlib/__init__.py#L1068-L1091\r\n\r\nWhat 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:\r\n1. `rcParams.clear()` doesn't work. It doesn't clear out the entire dictionary.\r\n2. 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.\r\n3. 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.\r\n\r\nAlso, sidenote, `popitem()` errors out without a good error message (which is also why clear doesn't actually empty the dict?)\n\n### Code for reproduction\n\n```python\nIn [3]: mpl.rcParams[\"webagg.port\"]\r\nOut[3]: 8988\r\n\r\nIn [4]: mpl.rcParams[\"webagg.port\"] = 9000\r\n\r\nIn [5]: mpl.rcParams[\"webagg.port\"]\r\nOut[5]: 9000\r\n\r\nIn [6]: mpl.rcdefaults()\r\n\r\nIn [7]: mpl.rcParams[\"webagg.port\"]\r\nOut[7]: 9000\r\n\r\nIn [8]: mpl.rcParams.clear()\r\n\r\nIn [9]: mpl.rcParams[\"webagg.port\"]\r\nOut[9]: 9000\n```\n\n\n### Actual outcome\n\n`clear()` doesn't empty the `rcParams` dictionary.\n\n### Expected outcome\n\n`clear()` should empty the dictionary and after `rcdefaults()`, keys from `STYLE_BLACKLIST` shouldn't be there.\n\n### Additional information\n\nI'm not sure if this is a documentation issue and the behaviour is intended or the behaviour isn't intended.\n\n### Operating system\n\n_No response_\n\n### Matplotlib Version\n\nCurrent main\n\n### Matplotlib Backend\n\n_No response_\n\n### Python version\n\n_No response_\n\n### Jupyter version\n\n_No response_\n\n### Installation\n\nNone","author":{"url":"https://github.com/chahak13","@type":"Person","name":"chahak13"},"datePublished":"2023-05-11T04:40:21.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":9},"url":"https://github.com/25855/matplotlib/issues/25855"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:f385f56c-5941-a538-90b3-801188e968a4 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A386:1FF3C2:1A1FC93:22C67FC:6A52CAAA |
| html-safe-nonce | b66e68d9fe321be06dc9ce47f802f3ef7e5911bc91fadc71ff14746adfd49633 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMzg2OjFGRjNDMjoxQTFGQzkzOjIyQzY3RkM6NkE1MkNBQUEiLCJ2aXNpdG9yX2lkIjoiNDMwNzcxOTc4NTgzMDA3NTA1MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | d7e55850c0edf3d8f646397e1a1522aaa1e5e5b412bbcce646a8c9ec5f969a9e |
| hovercard-subject-tag | issue:1705052486 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/matplotlib/matplotlib/25855/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ef56e89a290c678363c67f9caf9fe08229173f96ea86c48378cdd9c352266dd9/matplotlib/matplotlib/issues/25855 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ef56e89a290c678363c67f9caf9fe08229173f96ea86c48378cdd9c352266dd9/matplotlib/matplotlib/issues/25855 |
| og:image:alt | Bug summary This is the rcdefaults() function matplotlib/lib/matplotlib/__init__.py Lines 1068 to 1091 in 8faa835 def rcdefaults(): """ Restore the `.rcParams` from Matplotlib's internal default st... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | chahak13 |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| go-import | github.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git |
| octolytics-dimension-user_id | 215947 |
| octolytics-dimension-user_login | matplotlib |
| octolytics-dimension-repository_id | 1385122 |
| octolytics-dimension-repository_nwo | matplotlib/matplotlib |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1385122 |
| octolytics-dimension-repository_network_root_nwo | matplotlib/matplotlib |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 07a982c1d40157c619b364352b704c3ce66bb332 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width