Title: [Bug]: Setting aspect back to auto cannot recover the original 3D plot · Issue #31276 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: Setting aspect back to auto cannot recover the original 3D plot · Issue #31276 · matplotlib/matplotlib
X Title: [Bug]: Setting aspect back to auto cannot recover the original 3D plot · Issue #31276 · matplotlib/matplotlib
Description: Bug summary This bug arises when I plot filled contours with 3d projection and auto aspect, and save the figure as '3d-plot1.png'. Then, I set the aspect to 'equal' and back to 'auto', and save the figure as '3d-plot2.png', which is inco...
Open Graph Description: Bug summary This bug arises when I plot filled contours with 3d projection and auto aspect, and save the figure as '3d-plot1.png'. Then, I set the aspect to 'equal' and back to 'auto', and save the...
X Description: Bug summary This bug arises when I plot filled contours with 3d projection and auto aspect, and save the figure as '3d-plot1.png'. Then, I set the aspect to 'equal' and back to '...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/31276
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: Setting aspect back to auto cannot recover the original 3D plot","articleBody":"### Bug summary\n\nThis bug arises when I plot filled contours with 3d projection and auto aspect, and save the figure as '3d-plot1.png'. Then, I set the aspect to `'equal'` and back to `'auto'`, and save the figure as '3d-plot2.png', which is inconsistent with '3d-plot1.png'. However, this bug does not occur in 2d filled contours.\n\n### Code for reproduction\n\n```Python\nimport matplotlib.pyplot as plt\nfrom mpl_toolkits.mplot3d import axes3d\n\nfig1 = plt.figure()\nax1 = fig1.add_subplot(projection=None)\nX, Y, Z = axes3d.get_test_data()\nax1.contourf(X, Y, Z, cmap=\"coolwarm\")\nax1.set_aspect('auto')\nfig1.savefig('2d-plot1.png') # Correct\nax1.set_aspect('equal')\nax1.set_aspect('auto')\nfig1.savefig('2d-plot2.png') # Correct (consistent with 2d-plot1.png)\n\nfig2 = plt.figure()\nax2 = fig2.add_subplot(projection='3d')\nX, Y, Z = axes3d.get_test_data()\nax2.contourf(X, Y, Z, cmap=\"coolwarm\")\nax2.set_aspect('auto')\nfig2.savefig('3d-plot1.png') # Correct\nax2.set_aspect('equal')\nax2.set_aspect('auto')\nfig2.savefig('3d-plot2.png') # Wrong (inconsistent with 3d-plot1.png)\n```\n\n### Actual outcome\n\n#### 2d-plot1.png\n\n\u003cimg width=\"640\" height=\"480\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/b1a4eec5-cf8e-403a-a1cd-b9b07719d68e\" /\u003e\n\n#### 2d-plot2.png\n\n\u003cimg width=\"640\" height=\"480\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/d2a68576-5ae2-4ab4-80ee-d329009bbd31\" /\u003e\n\n#### 3d-plot1.png\n\n\u003cimg width=\"640\" height=\"480\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/0169e96b-97ca-4312-b38c-d049f5538cb3\" /\u003e\n\n#### 3d-plot2.png\n\n\u003cimg width=\"640\" height=\"480\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/e7d40002-9637-4f5f-a851-43daea06fdd0\" /\u003e\n\n### Expected outcome\n\n3d-plot2.png should be the same as 3d-plot1.png.\n\n### Additional information\n\n_No response_\n\n### Operating system\n\n_No response_\n\n### Matplotlib Version\n\n3.10.8\n\n### Matplotlib Backend\n\n_No response_\n\n### Python version\n\n_No response_\n\n### Jupyter version\n\n_No response_\n\n### Installation\n\nNone","author":{"url":"https://github.com/smith2936","@type":"Person","name":"smith2936"},"datePublished":"2026-03-11T07:32:56.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/31276/matplotlib/issues/31276"}
| 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:89ed2f48-4275-4075-3f36-d75ee2ad36f6 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | EBBA:1A1F1B:49983FD:67035F8:6A4F8530 |
| html-safe-nonce | d323548baf80ae57fa676f26c517933f2c3ff74de9ee991b5488b7b01abbec61 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQkJBOjFBMUYxQjo0OTk4M0ZEOjY3MDM1Rjg6NkE0Rjg1MzAiLCJ2aXNpdG9yX2lkIjoiMzUwODg3NTUxODI0OTIzOTg1NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | f7195e870624efa6b6560f633290438444652f9c41748fbb26331cf25a30f925 |
| hovercard-subject-tag | issue:4056452198 |
| 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/31276/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f0bd05888cf0bd227c374d94a973fe94b644d028a5af4d1a191b0d897511a2be/matplotlib/matplotlib/issues/31276 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f0bd05888cf0bd227c374d94a973fe94b644d028a5af4d1a191b0d897511a2be/matplotlib/matplotlib/issues/31276 |
| og:image:alt | Bug summary This bug arises when I plot filled contours with 3d projection and auto aspect, and save the figure as '3d-plot1.png'. Then, I set the aspect to 'equal' and back to 'auto', and save the... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | smith2936 |
| hostname | github.com |
| expected-hostname | github.com |
| None | b92d11c0aa4a77d54ef4af1078b6a15fb5a70a215b30c4ecf28889d5a8e656d9 |
| 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 | 4b249b445842943ed31549e027f57a8ade9881ed |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width