Title: [ENH]: Does pyplot need to call switch_backend · Issue #22739 · matplotlib/matplotlib · GitHub
Open Graph Title: [ENH]: Does pyplot need to call switch_backend · Issue #22739 · matplotlib/matplotlib
X Title: [ENH]: Does pyplot need to call switch_backend · Issue #22739 · matplotlib/matplotlib
Description: Problem It seems that simply importing pyplot can have serious effects on what backends are chosen, and how they interact with one and other. In matplotlib/lib/matplotlib/__init__.py Line 1137 in da9533d # if pyplot is not already import...
Open Graph Description: Problem It seems that simply importing pyplot can have serious effects on what backends are chosen, and how they interact with one and other. In matplotlib/lib/matplotlib/__init__.py Line 1137 in d...
X Description: Problem It seems that simply importing pyplot can have serious effects on what backends are chosen, and how they interact with one and other. In matplotlib/lib/matplotlib/__init__.py Line 1137 in d...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/22739
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[ENH]: Does pyplot need to call switch_backend","articleBody":"### Problem\n\nIt seems that simply importing pyplot can have serious effects on what backends are chosen, and how they interact with one and other.\r\n\r\nIn https://github.com/matplotlib/matplotlib/blob/da9533d507c1f06ceee5078c9cbbd99897809d31/lib/matplotlib/__init__.py#L1137\r\n\r\nThey say that simply\r\n```\r\nfrom matplotlib import pyplot\r\n```\r\ncan trigger setting the default backend.\r\n\r\nThis is somewhat frustrating for people who use interactive sessions.\r\n\r\nRunning the code\r\n```\r\nfrom matplotlib import pyplot\r\nimport matplotlib\r\nmatplotlib.use(\"WxAgg\")\r\n```\r\nall at once will work in ipython (from the terminal). But running it one line at a time, won't.\r\n\r\nThis is somewhat strange.\r\n\r\nNow that things like `__getattr__` exist, would be possible to further delay setting the default backend?\r\n\r\nThe issue arises when you want to build an application, and other people's code might be imported before yours. You are then at their mercy to not set the backend (implicitly!) before you set yours.\n\n### Proposed solution\n\nNo solution. I'm sure there is some strange historic thing I'm missing.\r\n\r\nHonestly, you created a great API with pyplot. People use it to get colormaps, and for all sorts of things.\r\n\r\n\r\n\r\nXREF: https://github.com/DeepLabCut/DeepLabCut/pull/1730","author":{"url":"https://github.com/hmaarrfk","@type":"Person","name":"hmaarrfk"},"datePublished":"2022-03-31T03:29:19.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":20},"url":"https://github.com/22739/matplotlib/issues/22739"}
| 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:7d74113c-c57a-cb0b-d34a-da92f5aac318 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A506:286752:1F2974:2A6758:6A51333F |
| html-safe-nonce | 7d40fc3c27b44baf6d39ec0498edf8483f537c14d2a83e953b3b59ed276ffed6 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNTA2OjI4Njc1MjoxRjI5NzQ6MkE2NzU4OjZBNTEzMzNGIiwidmlzaXRvcl9pZCI6Ijg2NTQxMTA0Mzc1MDIxNjk5MjAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | ce6d98f20dcb4b7be1184690fac05210113eb4b05baf700732587822d538a059 |
| hovercard-subject-tag | issue:1187445077 |
| 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/22739/issue_layout |
| twitter:image | https://opengraph.githubassets.com/64c4f6665ae4347d70bb45b6e413c7d1ab838096b90287764926e58c7d76c7a7/matplotlib/matplotlib/issues/22739 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/64c4f6665ae4347d70bb45b6e413c7d1ab838096b90287764926e58c7d76c7a7/matplotlib/matplotlib/issues/22739 |
| og:image:alt | Problem It seems that simply importing pyplot can have serious effects on what backends are chosen, and how they interact with one and other. In matplotlib/lib/matplotlib/__init__.py Line 1137 in d... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | hmaarrfk |
| hostname | github.com |
| expected-hostname | github.com |
| None | e840f405b2718e8f2d55aafa9ff27dbce17e29d0c253011d05ea0fea3c78baff |
| 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 | 4ae6027e8ba70c79dc08249bb6cdc1a09d788496 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width