Title: [Bug]: pyplot.subplot_tool doesn't always return a SubplotTool · Issue #31979 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: pyplot.subplot_tool doesn't always return a SubplotTool · Issue #31979 · matplotlib/matplotlib
X Title: [Bug]: pyplot.subplot_tool doesn't always return a SubplotTool · Issue #31979 · matplotlib/matplotlib
Description: Bug summary Per the matplotlib.pyplot.subplot_tool documentation, the return value is suppose to be a matplotlib.widgets.SubplotTool instance. In pyplot.py, the type hint also specifies that None can be returned: def subplot_tool(targetf...
Open Graph Description: Bug summary Per the matplotlib.pyplot.subplot_tool documentation, the return value is suppose to be a matplotlib.widgets.SubplotTool instance. In pyplot.py, the type hint also specifies that None c...
X Description: Bug summary Per the matplotlib.pyplot.subplot_tool documentation, the return value is suppose to be a matplotlib.widgets.SubplotTool instance. In pyplot.py, the type hint also specifies that None c...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/31979
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: pyplot.subplot_tool doesn't always return a SubplotTool","articleBody":"### Bug summary\n\nPer the [matplotlib.pyplot.subplot_tool documentation](https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.subplot_tool.html#matplotlib.pyplot.subplot_tool), the return value is suppose to be a `matplotlib.widgets.SubplotTool` instance.\n\nIn pyplot.py, the type hint also specifies that None can be returned:\n\n```python\ndef subplot_tool(targetfig: Figure | None = None) -\u003e SubplotTool | None:\n \"\"\"\n Launch a subplot tool window for a figure.\n\n Returns\n -------\n `matplotlib.widgets.SubplotTool`\n \"\"\"\n```\n\nHowever, when using the qtagg backend, a `SubplotToolQt` instance is returned. Despite the name, it doesn't inherit from `SubplotTool`, only `QtWidgets.QDialog`.\n\nI think there are multiple issues here:\n\n1. The documentation should mention the None case\n2. `configure_subplot` in `backend_bases.pyi` should have a type hint with a return value of `widgets.SubplotTool | None`.\n3. qtagg should then return `None` from its configure_subplot method.\n\nAlternatively, `SubplotToolQt` should inherit from both `SubplotTool` and `QtWidgets.QDialog`, but I'm not sure what all that would entail.\n\n### Code for reproduction\n\n```Python\nimport matplotlib.pyplot as plt\nimport matplotlib\nimport numpy as np\n\nx = np.linspace(0, 10, 100)\nfig, ax = plt.subplots()\nax.plot(x, np.sin(x))\n\ntool = plt.subplot_tool()\nif tool:\n assert isinstance(tool, matplotlib.widgets.SubplotTool)\n\nplt.show()\n```\n\n### Actual outcome\n\nAssertionError\n\n### Expected outcome\n\nNo assertion.\n\n### Additional information\n\n_No response_\n\n### Operating system\n\n_No response_\n\n### Matplotlib Version\n\n3.11\n\n### Matplotlib Backend\n\nqtagg\n\n### Python version\n\n3.14.5\n\n### Jupyter version\n\n_No response_\n\n### Installation\n\nNone","author":{"url":"https://github.com/iccir","@type":"Person","name":"iccir"},"datePublished":"2026-07-02T02:52:14.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/31979/matplotlib/issues/31979"}
| 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:ed7a572c-4362-a2f3-fe6b-b97d3c15fbbb |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | ACFE:2A0782:314C82F:4317A5B:6A53EBB2 |
| html-safe-nonce | 193cf576faa68da36fdc30bf62d2abd47dccaed2180e638198de2aba82d30a53 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQ0ZFOjJBMDc4MjozMTRDODJGOjQzMTdBNUI6NkE1M0VCQjIiLCJ2aXNpdG9yX2lkIjoiMTg0NTE0Njc2Mjc4NjEwNjI5MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 34a8624998b4078cc0498e54cd569e92077903374420ab2dbf8ed1c6a6fa9af0 |
| hovercard-subject-tag | issue:4790823042 |
| 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/31979/issue_layout |
| twitter:image | https://opengraph.githubassets.com/eb9cb0077ec4adb1d26fb1a2f2731beef8f0ac84bd416e852630dfaa2f90d700/matplotlib/matplotlib/issues/31979 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/eb9cb0077ec4adb1d26fb1a2f2731beef8f0ac84bd416e852630dfaa2f90d700/matplotlib/matplotlib/issues/31979 |
| og:image:alt | Bug summary Per the matplotlib.pyplot.subplot_tool documentation, the return value is suppose to be a matplotlib.widgets.SubplotTool instance. In pyplot.py, the type hint also specifies that None c... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | iccir |
| 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