Title: [Bug]: typehint missing for matplotlib Axes · Issue #28210 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: typehint missing for matplotlib Axes · Issue #28210 · matplotlib/matplotlib
X Title: [Bug]: typehint missing for matplotlib Axes · Issue #28210 · matplotlib/matplotlib
Description: Bug summary plt.subplots in matplotlib 3.8.0 returns tuple[Figure, Any], so Pylance doesn't know the type of ax Code for reproduction import matplotlib.pyplot as plt from matplotlib.axes import Axes # added this fig, ax = plt.subplots() ...
Open Graph Description: Bug summary plt.subplots in matplotlib 3.8.0 returns tuple[Figure, Any], so Pylance doesn't know the type of ax Code for reproduction import matplotlib.pyplot as plt from matplotlib.axes import Axe...
X Description: Bug summary plt.subplots in matplotlib 3.8.0 returns tuple[Figure, Any], so Pylance doesn't know the type of ax Code for reproduction import matplotlib.pyplot as plt from matplotlib.axes import...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/28210
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: typehint missing for matplotlib Axes","articleBody":"### Bug summary\n\nplt.subplots in matplotlib 3.8.0 returns `tuple[Figure, Any]`, so Pylance doesn't know the type of `ax`\n\n### Code for reproduction\n\n```Python\nimport matplotlib.pyplot as plt\r\nfrom matplotlib.axes import Axes # added this\r\n\r\nfig, ax = plt.subplots()\r\nax: Axes # added this\r\n\r\nfruits = ['apple', 'blueberry', 'cherry', 'orange']\r\ncounts = [40, 100, 30, 55]\r\ncolours = ['red', 'blue', 'red', 'orange']\r\n\r\nax.bar(fruits, counts, label=colours, color=colours)\r\n\r\nax.set_ylabel('fruit supply')\r\nax.set_title('Fruit supply by kind and color')\r\nax.legend(title='Fruit color')\r\n\r\nplt.show()\n```\n\n\n### Actual outcome\n\nThe intelisense does not work for `ax` so it has to be explicitly typehinted.\n\n### Expected outcome\n\nThe import of `Axes` and the typehint of `ax` should not be required.\n\n### Additional information\n\nplease see this stackoverflow link: https://stackoverflow.com/questions/77368904/methods-and-attributes-do-not-show-when-dot-is-pressed-intellisense\n\n### Operating system\n\nwindows 11\n\n### Matplotlib Version\n\n3.8.0\n\n### Matplotlib Backend\n\nTkAgg\n\n### Python version\n\n3.12\n\n### Jupyter version\n\n_No response_\n\n### Installation\n\npip","author":{"url":"https://github.com/dlefcoe","@type":"Person","name":"dlefcoe"},"datePublished":"2024-05-12T09:35:05.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/28210/matplotlib/issues/28210"}
| 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:a6c27d3f-adf0-ebe5-347d-324e540817b0 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A326:2E411E:181092B:208B57A:6A535CDA |
| html-safe-nonce | fe90bdc4a651a848958040db63b78d0187836e741b10dc67e6756e261276556b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMzI2OjJFNDExRToxODEwOTJCOjIwOEI1N0E6NkE1MzVDREEiLCJ2aXNpdG9yX2lkIjoiNzExNDU5Mjk0MzY5MzA2MTMzOCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 61597e4c9a8eb40dd3b0f5d001154a85eea6ce55fbe0fc7c713a288f6aa49ba3 |
| hovercard-subject-tag | issue:2291253630 |
| 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/28210/issue_layout |
| twitter:image | https://opengraph.githubassets.com/867c152b0bdc2f6ff54446ed59cfde1d02d47a19c2fc14a7166cd0903a5e1a2a/matplotlib/matplotlib/issues/28210 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/867c152b0bdc2f6ff54446ed59cfde1d02d47a19c2fc14a7166cd0903a5e1a2a/matplotlib/matplotlib/issues/28210 |
| og:image:alt | Bug summary plt.subplots in matplotlib 3.8.0 returns tuple[Figure, Any], so Pylance doesn't know the type of ax Code for reproduction import matplotlib.pyplot as plt from matplotlib.axes import Axe... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dlefcoe |
| 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