Title: Fix docstring `lib/matplotlib/pyplot.py` and related `lib/matplotlib/__init__.py` by alberti42 · Pull Request #31168 · matplotlib/matplotlib · GitHub
Open Graph Title: Fix docstring `lib/matplotlib/pyplot.py` and related `lib/matplotlib/__init__.py` by alberti42 · Pull Request #31168 · matplotlib/matplotlib
X Title: Fix docstring `lib/matplotlib/pyplot.py` and related `lib/matplotlib/__init__.py` by alberti42 · Pull Request #31168 · matplotlib/matplotlib
Description: PR summary The docstrings for matplotlib.use and pyplot.switch_backend both claim that switching to a different backend will close all open figures via plt.close('all'). However, the implementation of switch_backend never actually calls close('all') — open figures survive backend switches. This PR removes the inaccurate claims from both docstrings. Repro confirming figures are not closed: gui_backend = "macosx" import matplotlib matplotlib.use(gui_backend) import matplotlib.pyplot as plt # First figure in the GUI (non-blocking) fig1, ax1 = plt.subplots() ax1.plot([1, 2, 3], [1, 4, 9]) ax1.set_title("Figure 1 (macosx)") fig1.show() # Switch to SVG backend and save a figure to disk plt.switch_backend("svg") fig2, ax2 = plt.subplots() ax2.plot([1, 2, 3], [9, 4, 1]) ax2.set_title("Figure 2 (svg)") fig2.savefig("output.svg") # Switch back to the GUI backend and create another figure plt.switch_backend(gui_backend) fig3, ax3 = plt.subplots() ax3.plot([1, 2, 3], [2, 5, 2]) ax3.set_title("Figure 3 (macosx)") fig3.show() plt.show(block=False) Both GUI windows remain open and output.svg is created on disk. PR checklist [N/A] "closes #0000" is in the body of the PR description to link the related issue [N/A] new and changed code is tested Plotting related features are demonstrated in an example [N/A] New Features and API Changes are noted with a directive and release note Documentation complies with general and docstring guidelines
Open Graph Description: PR summary The docstrings for matplotlib.use and pyplot.switch_backend both claim that switching to a different backend will close all open figures via plt.close('all'). However, the implem...
X Description: PR summary The docstrings for matplotlib.use and pyplot.switch_backend both claim that switching to a different backend will close all open figures via plt.close('all'). However, th...
Opengraph URL: https://github.com/matplotlib/matplotlib/pull/31168
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:4866dc40-6dc6-9e24-83f2-68bd2626066d |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | D6D0:34F6B9:124145:180C4B:6A51B36E |
| html-safe-nonce | d390112d488638dc98bd63505781e6fd117a8e49d74991cf3183f3e3722f9e1b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENkQwOjM0RjZCOToxMjQxNDU6MTgwQzRCOjZBNTFCMzZFIiwidmlzaXRvcl9pZCI6IjU1NDc4NTgxNDMzNDQ3MDIzMTgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 828987cd441f131ce7243b25b6d0d61e8259b8a72af72732bd9f08ea1aeef98d |
| hovercard-subject-tag | pull_request:3294255148 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,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/matplotlib/matplotlib/pull/31168/files |
| twitter:image | https://avatars.githubusercontent.com/u/61808?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/61808?s=400&v=4 |
| og:image:alt | PR summary The docstrings for matplotlib.use and pyplot.switch_backend both claim that switching to a different backend will close all open figures via plt.close('all'). However, the implem... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| diff-view | unified |
| 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 full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 7aed05249554b889eb33d002851a973eebcc7e91 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width