Title: [Bug]: rcParams["interactive"] is overwritten if rc_context is used before anything else · Issue #24351 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: rcParams["interactive"] is overwritten if rc_context is used before anything else · Issue #24351 · matplotlib/matplotlib
X Title: [Bug]: rcParams["interactive"] is overwritten if rc_context is used before anything else · Issue #24351 · matplotlib/matplotlib
Description: Bug summary rcParams["interactive"] is set based on environment upon the user's first call to plot some figure. However, if that call is wrapped with @mpl.rc_context (or does some sort of caching the original rcParams), it saves the defa...
Open Graph Description: Bug summary rcParams["interactive"] is set based on environment upon the user's first call to plot some figure. However, if that call is wrapped with @mpl.rc_context (or does some sort of caching t...
X Description: Bug summary rcParams["interactive"] is set based on environment upon the user's first call to plot some figure. However, if that call is wrapped with @mpl.rc_context (or does some sor...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/24351
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: rcParams[\"interactive\"] is overwritten if rc_context is used before anything else","articleBody":"### Bug summary\n\n`rcParams[\"interactive\"]` is set based on environment upon the user's first call to plot some figure. However, if that call is wrapped with `@mpl.rc_context` (or does some sort of caching the original `rcParams`), it saves the default value of `interactive=False` and then restores it regardless of whether or not it has been updated to True.\n\n### Code for reproduction\n\n```python\n### in an interactive environment such as a Jupyter notebook:\r\n\r\nimport matplotlib as mpl\r\nfrom matplotlib import pyplot as plt\r\nimport numpy as np\r\n\r\ny = np.linspace(1,100,100) ** 2\r\n\r\nwith mpl.rc_context({'lines.linestyle': '--'}):\r\n plt.plot(y)\r\n\r\n\r\n### In another Jupyter cell:\r\n\r\nplt.plot(y)\n```\n\n\n### Actual outcome\n\n\r\n\n\n### Expected outcome\n\n\r\n\n\n### Additional information\n\nIf the value of rcParams[\"interactive\"] was fetched and added to `orig` in the `finally` block [here](https://github.com/matplotlib/matplotlib/blob/0b6d3703ff43ae87815dcc891c56e7a7c50ce5ff/lib/matplotlib/__init__.py#L1111), this should fix it. You'd have to ensure that the calling `rc` or `fname` didn't override `interactive` manually, so this change might require some additional care.\n\n### Operating system\n\nMacOS\n\n### Matplotlib Version\n\n3.5.3\n\n### Matplotlib Backend\n\nmodule://matplotlib_inline.backend_inline\n\n### Python version\n\n3.9.13\n\n### Jupyter version\n\n6.4.12\n\n### Installation\n\npip","author":{"url":"https://github.com/timmysilv","@type":"Person","name":"timmysilv"},"datePublished":"2022-11-03T14:25:35.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":5},"url":"https://github.com/24351/matplotlib/issues/24351"}
| 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:63c27ce8-c50d-9743-f630-fb5805ef6cc4 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BDD2:B267E:461F55:5F0704:6A51C579 |
| html-safe-nonce | e8da9c9948913fb258343050d9adf34b1572a4e7262d0e124f91c139a5e8a32f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCREQyOkIyNjdFOjQ2MUY1NTo1RjA3MDQ6NkE1MUM1NzkiLCJ2aXNpdG9yX2lkIjoiNjYzNzEzMDY3MjE2NjI1ODA0MSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 94457c08b1e1e8fa44d0f4c4e1e23a3da6e79f8da17f4044aef7aea45067f8db |
| hovercard-subject-tag | issue:1434753010 |
| 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/24351/issue_layout |
| twitter:image | https://opengraph.githubassets.com/522e4e98af71bdfdb7239c352ae4ef2e8919025f6da017ac8dfd33af0fc39fc7/matplotlib/matplotlib/issues/24351 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/522e4e98af71bdfdb7239c352ae4ef2e8919025f6da017ac8dfd33af0fc39fc7/matplotlib/matplotlib/issues/24351 |
| og:image:alt | Bug summary rcParams["interactive"] is set based on environment upon the user's first call to plot some figure. However, if that call is wrapped with @mpl.rc_context (or does some sort of caching t... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | timmysilv |
| 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 | 7aed05249554b889eb33d002851a973eebcc7e91 |
| ui-target | canary-1 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width