Title: [Bug]: `tight` and `constrained` layouts honouring invisible parts of `floating_axis` · Issue #31622 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: `tight` and `constrained` layouts honouring invisible parts of `floating_axis` · Issue #31622 · matplotlib/matplotlib
X Title: [Bug]: `tight` and `constrained` layouts honouring invisible parts of `floating_axis` · Issue #31622 · matplotlib/matplotlib
Description: Bug summary Using the tight or constrained layouts will not make the figure any smaller than the full size of a floating axis, even accounting for parts of the floating axis that are outside the visible plot area. This can actually incre...
Open Graph Description: Bug summary Using the tight or constrained layouts will not make the figure any smaller than the full size of a floating axis, even accounting for parts of the floating axis that are outside the vi...
X Description: Bug summary Using the tight or constrained layouts will not make the figure any smaller than the full size of a floating axis, even accounting for parts of the floating axis that are outside the vi...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/31622
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: `tight` and `constrained` layouts honouring invisible parts of `floating_axis`","articleBody":"### Bug summary\n\nUsing the `tight` or `constrained` layouts will not make the figure any smaller than the full size of a floating axis, even accounting for parts of the floating axis that are outside the visible plot area. This can actually _increase_ the figure size compared to the 'default' layout (i.e. `None`).\n\n### Code for reproduction\n\n```Python\nimport matplotlib.pyplot as plt\nimport numpy as np\n\nfrom matplotlib.projections import PolarAxes\nfrom matplotlib.transforms import Affine2D\nfrom mpl_toolkits.axisartist import GridHelperCurveLinear, HostAxes\n\n\ndef polar_plot(fig):\n # Adapted from https://matplotlib.org/stable/gallery/axisartist/demo_floating_axis.html\n tr = (\n Affine2D().scale(np.pi / 180., 1.) +\n PolarAxes.PolarTransform(apply_theta_transforms=False)\n )\n grid_helper = GridHelperCurveLinear(tr)\n ax1 = fig.add_subplot(axes_class=HostAxes, grid_helper=grid_helper)\n ax1.axis[\"lon\"] = ax1.new_floating_axis(1, 9)\n\n ax1.set_xlim(-5, 12)\n ax1.set_ylim(-5, 10)\n ax1.grid(True)\n for key, val in ax1.axis.items():\n val.major_ticklabels.set_visible(False)\n\n\ndef main():\n for layout in [None, \"tight\", \"constrained\"]:\n my_fig = plt.figure(figsize=(5, 5), layout=layout)\n polar_plot(my_fig)\n layout_str = layout if layout is not None else \"default\"\n plt.title(f\"Layout: {layout_str}\")\n plt.savefig(f\"floating_axis_{layout_str}.png\")\n\n\nif __name__ == \"__main__\":\n main()\n```\n\n### Actual outcome\n\n\u003cimg width=\"200\" height=\"200\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/30bb8c67-7f1c-46e7-bc90-ade84cd60f22\" /\u003e\n\u003cimg width=\"200\" height=\"200\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/593f2fd1-0738-4102-9a27-76dc60626724\" /\u003e\n\u003cimg width=\"200\" height=\"200\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/19a61152-f595-4864-bf5f-c4ab6f1613c6\" /\u003e\n\n### Expected outcome\n\n\u003cimg width=\"500\" height=\"500\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/fae6707d-bff1-42a1-86fb-c39955cc4d18\" /\u003e\n\n### Additional information\n\nI am assuming this is an unintended bug because the default `None` layout does not size the figure to account for the non-visible parts of the floating axis.\n\nThis behaviour was introduced by the below pull request, first released in Matplotlib 3.7:\n\n- #24085\n\n### Operating system\n\nLinux RHEL9\n\n### Matplotlib Version\n\n3.10.0\n\n### Matplotlib Backend\n\nqtagg\n\n### Python version\n\n3.10.0\n\n### Jupyter version\n\nN/A\n\n### Installation\n\nconda","author":{"url":"https://github.com/trexfeathers","@type":"Person","name":"trexfeathers"},"datePublished":"2026-05-06T17:21:04.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/31622/matplotlib/issues/31622"}
| 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:668e64c5-6e4f-1282-7bd0-5dd4eceb45e1 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BDCE:25F5DD:D0F55:111689:6A526E96 |
| html-safe-nonce | 933dc0421d40722aad758c4147361c92126e5e1f1132869855e04c79be0aa229 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRENFOjI1RjVERDpEMEY1NToxMTE2ODk6NkE1MjZFOTYiLCJ2aXNpdG9yX2lkIjoiODAxNDc1OTk0Nzk2MjMxNDM5MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 9051cf979dbd96e210c3ba1a77de51d37b8ad6d6351c4628dba66763e3ebbe17 |
| hovercard-subject-tag | issue:4393193318 |
| 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/31622/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d8f4fb1af8eca40e2c36fc8bb32ce29a3029b39654fa72f829dabe4b77518de5/matplotlib/matplotlib/issues/31622 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d8f4fb1af8eca40e2c36fc8bb32ce29a3029b39654fa72f829dabe4b77518de5/matplotlib/matplotlib/issues/31622 |
| og:image:alt | Bug summary Using the tight or constrained layouts will not make the figure any smaller than the full size of a floating axis, even accounting for parts of the floating axis that are outside the vi... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | trexfeathers |
| 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