Title: [Bug]: add_subfigure does not respect GridSpec parameters · Issue #28132 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: add_subfigure does not respect GridSpec parameters · Issue #28132 · matplotlib/matplotlib
X Title: [Bug]: add_subfigure does not respect GridSpec parameters · Issue #28132 · matplotlib/matplotlib
Description: Bug summary According the documentation for Figure.add_subfigure, you should be able to use GridSpec to create a set of subfigures to fill a certain space of a parent figure. However, no matter what settings are input into GridSpec, the ...
Open Graph Description: Bug summary According the documentation for Figure.add_subfigure, you should be able to use GridSpec to create a set of subfigures to fill a certain space of a parent figure. However, no matter wha...
X Description: Bug summary According the documentation for Figure.add_subfigure, you should be able to use GridSpec to create a set of subfigures to fill a certain space of a parent figure. However, no matter wha...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/28132
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: add_subfigure does not respect GridSpec parameters","articleBody":"### Bug summary\n\nAccording the documentation for `Figure.add_subfigure`, you should be able to use `GridSpec` to create a set of subfigures to fill a certain space of a parent figure. However, no matter what settings are input into `GridSpec`, the parent figure is divided into equally sized subfigures. Doing this same process with `Figure.add_subplot` produces the expected results with the axes bounded by the input extent and separated by the correct `hspace` and `wspace`.\n\n### Code for reproduction\n\n```Python\nimport matplotlib.pyplot as plt\r\nfrom matplotlib.gridspec import GridSpec\r\nimport numpy as np\r\n\r\ndpi = 100\r\nwidth = 600\r\nheight = 600\r\n\r\nmain = plt.figure(figsize=(width / dpi, height / dpi), dpi=100,\r\n facecolor='#9a9a9a', frameon=False)\r\n\r\ngs = GridSpec(2, 4, left=.1, right=.9, bottom=0.1,\r\n top=0.9, wspace=0.15, hspace=0.15)\r\n\r\ncolors = np.array([\r\n ['red', 'black', 'green', 'blue'],\r\n ['brown', 'gray', 'white', 'gold']\r\n])\r\n\r\npanels = []\r\nfor row in range(2):\r\n for col in range(4):\r\n main.add_subfigure(gs[row, col], facecolor=colors[row][col])\r\n\r\nplt.show()\n```\n\n\n### Actual outcome\n\nThe output is equally sized subfigures without any space between them and the full extent being used despite the input restrictions.\r\n\r\n\n\n### Expected outcome\n\nWhat is expected is a properly spaced areas with the proper extent. This can be produced when using `add_subplot` instead of `add_subfigure`.\r\n\r\n\n\n### Additional information\n\n_No response_\n\n### Operating system\n\n_No response_\n\n### Matplotlib Version\n\n3.8.3\n\n### Matplotlib Backend\n\n_No response_\n\n### Python version\n\n3.12.2\n\n### Jupyter version\n\n_No response_\n\n### Installation\n\nconda","author":{"url":"https://github.com/nawendt","@type":"Person","name":"nawendt"},"datePublished":"2024-04-24T15:08:53.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/28132/matplotlib/issues/28132"}
| 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:2a0474c7-22d5-02f0-1b1c-97ac07a4f04c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A0C0:9FC62:C80F3B:10BEF0D:6A52C462 |
| html-safe-nonce | 7f000e73f0a7c8788d29731d78e68b6777b3a1c1ff32df16b2e2c322b7fb56cf |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMEMwOjlGQzYyOkM4MEYzQjoxMEJFRjBEOjZBNTJDNDYyIiwidmlzaXRvcl9pZCI6IjIxMjkxMzg4MzUxNDUyNzg1NjMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 453b2f34c2387eb9da3df4be7c21c459a9abc6b84be3bf9dc34de8207e3b87d9 |
| hovercard-subject-tag | issue:2261534166 |
| 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/28132/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4541236a1cb1555d5892334fa1c3df98283b0ee320f32385c728676f5e96782d/matplotlib/matplotlib/issues/28132 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4541236a1cb1555d5892334fa1c3df98283b0ee320f32385c728676f5e96782d/matplotlib/matplotlib/issues/28132 |
| og:image:alt | Bug summary According the documentation for Figure.add_subfigure, you should be able to use GridSpec to create a set of subfigures to fill a certain space of a parent figure. However, no matter wha... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | nawendt |
| 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