Title: [Doc]: `get_figure` may return a `SubFigure` · Issue #28170 · matplotlib/matplotlib · GitHub
Open Graph Title: [Doc]: `get_figure` may return a `SubFigure` · Issue #28170 · matplotlib/matplotlib
X Title: [Doc]: `get_figure` may return a `SubFigure` · Issue #28170 · matplotlib/matplotlib
Description: Documentation Link https://matplotlib.org/devdocs/api/_as_gen/matplotlib.artist.Artist.get_figure.html#matplotlib.artist.Artist.get_figure Problem I'm not sure whether this is a documentation issue or a bug. The docstring for get_figure ...
Open Graph Description: Documentation Link https://matplotlib.org/devdocs/api/_as_gen/matplotlib.artist.Artist.get_figure.html#matplotlib.artist.Artist.get_figure Problem I'm not sure whether this is a documentation issue...
X Description: Documentation Link https://matplotlib.org/devdocs/api/_as_gen/matplotlib.artist.Artist.get_figure.html#matplotlib.artist.Artist.get_figure Problem I'm not sure whether this is a documentation i...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/28170
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Doc]: `get_figure` may return a `SubFigure`","articleBody":"### Documentation Link\n\nhttps://matplotlib.org/devdocs/api/_as_gen/matplotlib.artist.Artist.get_figure.html#matplotlib.artist.Artist.get_figure\n\n### Problem\n\nI'm not sure whether this is a documentation issue or a bug. The docstring for `get_figure` states that it returns a `Figure`, which I think implies the parent figure. If our artist is on a subfigure, it will return that. Note that `SubFigure` does not inherit from `Figure`.\r\n\r\n```python\r\nIn [1]: import matplotlib.pyplot as plt\r\n\r\nIn [2]: fig = plt.figure()\r\n\r\nIn [3]: sfig = fig.subfigures()\r\n\r\nIn [4]: ax = sfig.subplots()\r\n\r\nIn [5]: ax.get_figure()\r\nOut[5]: \u003cmatplotlib.figure.SubFigure at 0x7dc0ddf4a870\u003e\r\n```\n\n### Suggested improvement\n\nEither\r\n* modify the docstring to clarify you might get the `SubFigure` (and point to how you can get the parent `Figure` if you want it)\r\nor\r\n* fix the method so it returns the parent `Figure`","author":{"url":"https://github.com/rcomer","@type":"Person","name":"rcomer"},"datePublished":"2024-05-04T11:37:47.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":8},"url":"https://github.com/28170/matplotlib/issues/28170"}
| 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:dbfb7dc2-7313-98df-2b83-d406c94bc0f1 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C1C8:25211B:2EC35AE:3F768A4:6A53D9EA |
| html-safe-nonce | 0e5eb27929943dca7eeb62c6d008e59061a26b786652aa4bad27ce5165cb2aa5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMUM4OjI1MjExQjoyRUMzNUFFOjNGNzY4QTQ6NkE1M0Q5RUEiLCJ2aXNpdG9yX2lkIjoiODA4NDE3NjU2OTc4MDA0NDU5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | d3bee2f013f39364ce9a6c838aa0b861d121e55c2673387e3a6c8774b8411fb0 |
| hovercard-subject-tag | issue:2278952309 |
| 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/28170/issue_layout |
| twitter:image | https://opengraph.githubassets.com/0db58adf9b829cd5a2c91cd12ad5967f9fe9f567c674a366b838b7043b1ce618/matplotlib/matplotlib/issues/28170 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/0db58adf9b829cd5a2c91cd12ad5967f9fe9f567c674a366b838b7043b1ce618/matplotlib/matplotlib/issues/28170 |
| og:image:alt | Documentation Link https://matplotlib.org/devdocs/api/_as_gen/matplotlib.artist.Artist.get_figure.html#matplotlib.artist.Artist.get_figure Problem I'm not sure whether this is a documentation issue... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | rcomer |
| 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