Title: [Bug]: savefig(bbox_inches='tight') clips axis labels on 3D axes · Issue #31568 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: savefig(bbox_inches='tight') clips axis labels on 3D axes · Issue #31568 · matplotlib/matplotlib
X Title: [Bug]: savefig(bbox_inches='tight') clips axis labels on 3D axes · Issue #31568 · matplotlib/matplotlib
Description: Bug summary savefig(bbox_inches='tight') clips the zlabel and xlabel on 3D axes. This happens because Axes3D.get_tightbbox() does not include axis labels in its bounding box calculation. On 2D axes this works correctly. Code for reproduc...
Open Graph Description: Bug summary savefig(bbox_inches='tight') clips the zlabel and xlabel on 3D axes. This happens because Axes3D.get_tightbbox() does not include axis labels in its bounding box calculation. On 2D axes...
X Description: Bug summary savefig(bbox_inches='tight') clips the zlabel and xlabel on 3D axes. This happens because Axes3D.get_tightbbox() does not include axis labels in its bounding box calculation. On...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/31568
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: savefig(bbox_inches='tight') clips axis labels on 3D axes","articleBody":"### Bug summary\n\n`savefig(bbox_inches='tight') `clips the `zlabel` and `xlabel` on 3D axes. This happens because `Axes3D.get_tightbbox() `does not include axis labels in its bounding box calculation. On 2D axes this works correctly.\n\n### Code for reproduction\n\n```Python\nimport matplotlib.pyplot as plt\n\nfig = plt.figure(figsize=(3, 3))\nax = fig.add_subplot(1, 1, 1, projection='3d')\nax.plot([0, 1], [0, 1], [0, 1])\nax.set_zlabel(\"Z axis label\")\nax.set_xlabel(\"X axis label\")\n\nfig.savefig(\"3d_tight.png\", bbox_inches='tight')\n```\n\n### Actual outcome\n\n`zlabel `and `xlabel `are clipped at the edges of the saved image.\n\n \n\n\u003cimg width=\"327\" height=\"351\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/cc98532a-99a4-42f6-9677-f5e65ff0dced\" /\u003e\n\nConfirmed numerically:\n```\ntightbbox: x1=296.0\nzlabel x1=321.2 → 25px outside tightbbox on the right\nxlabel y0=1.0 → 12px outside tightbbox at the bottom\n```\n\n### Expected outcome\n\nExpected outcome\nLabels should be fully visible, as they are when saving without`\n\n\u003cimg width=\"480\" height=\"360\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/7242bd8f-77c5-49ab-ae64-32cf62618425\" /\u003e\n\n`.\n\nOn 2D axes, `get_tightbbox`() always includes xlabel `tightbbox.y0 == xlabel.y0`. On 3D it does not.\n\n### Additional information\n\nRelated to the broader known issue of 3D axes not fully contributing to bounding box calculations, noted by @QuLogic in #31277. This specific symptom axis labels excluded from `get_tightbbox()` produces a concrete user-visible artifact in saved figures.\n\n### Operating system\n\n_No response_\n\n### Matplotlib Version\n\n3.10.8\n\n### Matplotlib Backend\n\nAgg\n\n### Python version\n\n_No response_\n\n### Jupyter version\n\n_No response_\n\n### Installation\n\npip","author":{"url":"https://github.com/buddy0452004","@type":"Person","name":"buddy0452004"},"datePublished":"2026-04-25T07:05:49.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/31568/matplotlib/issues/31568"}
| 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:2e00a61d-b58d-30ba-c52b-ee847af8e44d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DA30:1BD726:2A3A1E3:38E7EB4:6A54862E |
| html-safe-nonce | ffcbaa6a2837a1fe1389f4180cb41f853a23bc34bf34db2ae975ca86884349ff |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQTMwOjFCRDcyNjoyQTNBMUUzOjM4RTdFQjQ6NkE1NDg2MkUiLCJ2aXNpdG9yX2lkIjoiNTA2MzU4NDEwNTIyNjMzOTg4NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 18099e3cd9857d1800a688d55a8819ad1e44ecfc47a0e05f08849a46df2cd66a |
| hovercard-subject-tag | issue:4327439501 |
| 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/31568/issue_layout |
| twitter:image | https://opengraph.githubassets.com/396e74966253a1c55d7ca976f30dd093aa8372985a76027b4c62c7a123d8f0d6/matplotlib/matplotlib/issues/31568 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/396e74966253a1c55d7ca976f30dd093aa8372985a76027b4c62c7a123d8f0d6/matplotlib/matplotlib/issues/31568 |
| og:image:alt | Bug summary savefig(bbox_inches='tight') clips the zlabel and xlabel on 3D axes. This happens because Axes3D.get_tightbbox() does not include axis labels in its bounding box calculation. On 2D axes... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | buddy0452004 |
| 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 | 03ccb116376fd46e8ba2a4cdc541e35f13f70734 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width