Title: [Bug]: Resetting aspect to auto does not work for axes with twinx · Issue #31232 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: Resetting aspect to auto does not work for axes with twinx · Issue #31232 · matplotlib/matplotlib
X Title: [Bug]: Resetting aspect to auto does not work for axes with twinx · Issue #31232 · matplotlib/matplotlib
Description: Bug summary This bug occurs when I create a subplot with twin axes. Setting the aspect of axes from 'auto' to 'equal' works fine, but resetting the aspect back to 'auto' does not work. Code for reproduction import matplotlib.pyplot as pl...
Open Graph Description: Bug summary This bug occurs when I create a subplot with twin axes. Setting the aspect of axes from 'auto' to 'equal' works fine, but resetting the aspect back to 'auto' does not work. Code for rep...
X Description: Bug summary This bug occurs when I create a subplot with twin axes. Setting the aspect of axes from 'auto' to 'equal' works fine, but resetting the aspect back to 'auto' doe...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/31232
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: Resetting aspect to auto does not work for axes with twinx","articleBody":"### Bug summary\n\nThis bug occurs when I create a subplot with twin axes. Setting the `aspect` of axes from `'auto'` to `'equal'` works fine, but resetting the `aspect` back to `'auto'` does not work.\n\n### Code for reproduction\n\n```Python\nimport matplotlib.pyplot as plt\n\nfig = plt.figure()\nax = fig.add_subplot()\nax_twin = ax.twinx() # No bug if I remove this\nax.plot([0, 1, 2], [0, 2, 1])\n\nax.set_aspect('auto')\nplt.savefig('plot1.png')\nax.set_aspect('equal')\nplt.savefig('tmp.png') # No bug if I remove this\nax.set_aspect('auto')\nplt.savefig('plot2.png') # plot2.png should be the same as plot1.png\n```\n\n### Actual outcome\n\n#### plot1.png\n\n\u003cimg width=\"640\" height=\"480\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/beb8203c-70dc-4a5a-b2b5-4e87fbeea73c\" /\u003e\n\n#### plot2.png\n\n\u003cimg width=\"640\" height=\"480\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/c727f1b3-afcb-48e2-a186-fe00aa1e87b3\" /\u003e\n\n### Expected outcome\n\nplot2.png should be the same as 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/williamlus","@type":"Person","name":"williamlus"},"datePublished":"2026-03-04T11:05:10.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":7},"url":"https://github.com/31232/matplotlib/issues/31232"}
| 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:d9b9c219-2dd6-7b3f-5166-a71aefc62f06 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | EE30:2003E5:159061A:1C6F75D:6A51C03B |
| html-safe-nonce | f367ed32c592a9643738b37bd715e4de918aad77461d256f93d3083fbe672c3f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFRTMwOjIwMDNFNToxNTkwNjFBOjFDNkY3NUQ6NkE1MUMwM0IiLCJ2aXNpdG9yX2lkIjoiNzM0MTkyNjgwMzkxNTc4NDI1MSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 78fca73859c608cda21431d98ecfb01f6c4c9c37ef65503e5558725a9cd5f94c |
| hovercard-subject-tag | issue:4021409535 |
| 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/31232/issue_layout |
| twitter:image | https://opengraph.githubassets.com/0e1e57733c52fd701f9f6e748beed87ecdc1e7692faf3e42a9f432c3861cb27d/matplotlib/matplotlib/issues/31232 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/0e1e57733c52fd701f9f6e748beed87ecdc1e7692faf3e42a9f432c3861cb27d/matplotlib/matplotlib/issues/31232 |
| og:image:alt | Bug summary This bug occurs when I create a subplot with twin axes. Setting the aspect of axes from 'auto' to 'equal' works fine, but resetting the aspect back to 'auto' does not work. Code for rep... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | williamlus |
| 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 | 7aed05249554b889eb33d002851a973eebcc7e91 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width