Title: [Bug]: Cannot share both axis when setting aspect ratio · Issue #30203 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: Cannot share both axis when setting aspect ratio · Issue #30203 · matplotlib/matplotlib
X Title: [Bug]: Cannot share both axis when setting aspect ratio · Issue #30203 · matplotlib/matplotlib
Description: Bug summary matplotlib/lib/matplotlib/axes/_base.py Lines 2054 to 2058 in 5a10e4d if shared_x and shared_y: raise RuntimeError("set_aspect(..., adjustable='datalim') or " "axis('equal') are not allowed when both axes " "are shared. Try s...
Open Graph Description: Bug summary matplotlib/lib/matplotlib/axes/_base.py Lines 2054 to 2058 in 5a10e4d if shared_x and shared_y: raise RuntimeError("set_aspect(..., adjustable='datalim') or " "axis('equal') are not all...
X Description: Bug summary matplotlib/lib/matplotlib/axes/_base.py Lines 2054 to 2058 in 5a10e4d if shared_x and shared_y: raise RuntimeError("set_aspect(..., adjustable='datalim') or " "ax...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/30203
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: Cannot share both axis when setting aspect ratio","articleBody":"### Bug summary\n\nhttps://github.com/matplotlib/matplotlib/blob/5a10e4d29d2929a4093a42f9263c8237b2be6360/lib/matplotlib/axes/_base.py#L2054-L2058\n\nThis part is a strong regulation.\nPeople would like to share both x and y axes when setting the aspect ratio to a certain value.\nThough there will be a conflict in datalim between subplots, it is a minor problem to me.\n\nWhen I changed this part as below, it worked like a charm as I expected.\n```Python\nif shared_x and shared_y:\n return\n```\n\n### Code for reproduction\n\n```Python\n#!/usr/bin/env python\nfrom matplotlib import pyplot as plt\n\nfig, ax = plt.subplots(2,1, sharex=True, sharey=True)\n\n# Case 1\nax[0].plot(range(0,3), range(3,6))\nax[1].plot(range(10,13), range(0,3))\n\n# Case 2\n# ax[0].plot(range(3,6), range(0,3))\n# ax[1].plot(range(0,3), range(10,13))\n\nax[0].set_box_aspect(1)\nax[1].set_box_aspect(1)\nax[1].set_aspect('equal', adjustable='datalim', share=True)\n\nplt.show()\n```\n\n### Actual outcome\n\n File \"/home/ssrokyz/app/miniforge3/lib/python3.12/site-packages/matplotlib/backends/backend_qt.py\", line 508, in _draw_idle\n self.draw()\n File \"/home/ssrokyz/app/miniforge3/lib/python3.12/site-packages/matplotlib/backends/backend_agg.py\", line 382, in draw\n self.figure.draw(self.renderer)\n File \"/home/ssrokyz/app/miniforge3/lib/python3.12/site-packages/matplotlib/artist.py\", line 94, in draw_wrapper\n result = draw(artist, renderer, *args, **kwargs)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/home/ssrokyz/app/miniforge3/lib/python3.12/site-packages/matplotlib/artist.py\", line 71, in draw_wrapper\n return draw(artist, renderer)\n ^^^^^^^^^^^^^^^^^^^^^^\n File \"/home/ssrokyz/app/miniforge3/lib/python3.12/site-packages/matplotlib/figure.py\", line 3246, in draw\n artists = self._get_draw_artists(renderer)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/home/ssrokyz/app/miniforge3/lib/python3.12/site-packages/matplotlib/figure.py\", line 166, in _get_draw_artists\n ax.apply_aspect(locator(ax, renderer) if locator else None)\n File \"/home/ssrokyz/app/miniforge3/lib/python3.12/site-packages/matplotlib/axes/_base.py\", line 2061, in apply_aspect\n raise RuntimeError(\"set_aspect(..., adjustable='datalim') or \"\nRuntimeError: set_aspect(..., adjustable='datalim') or axis('equal') are not allowed when both axes are shared. Try set_aspect(..., adjustable='box').\n\n### Expected outcome\n\n\n\n### Additional information\n\n_No response_\n\n### Operating system\n\n_No response_\n\n### Matplotlib Version\n\n3.10.1\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/youngjae142","@type":"Person","name":"youngjae142"},"datePublished":"2025-06-21T14:22:47.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":12},"url":"https://github.com/30203/matplotlib/issues/30203"}
| 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:95d4feaf-2a89-ac63-9295-9dd1ff817fef |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9A24:30769A:C38381:104DD38:6A52C136 |
| html-safe-nonce | 3d86dc3b9b86413e3ab5f7470dd4a6ac8724e53ec220694a838a211e22ae016a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QTI0OjMwNzY5QTpDMzgzODE6MTA0REQzODo2QTUyQzEzNiIsInZpc2l0b3JfaWQiOiIzODU0OTkxMzc2MjYyNTQ1NzE4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 80664ea39a0a3c1f6a7a4a5cdbb210f15e5b5e07d2a63df3a16604bcd04adea3 |
| hovercard-subject-tag | issue:3165127883 |
| 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/30203/issue_layout |
| twitter:image | https://opengraph.githubassets.com/041d500f7ee581e40803f48180b16783ef5cb89fb2e83eec973096f874912aec/matplotlib/matplotlib/issues/30203 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/041d500f7ee581e40803f48180b16783ef5cb89fb2e83eec973096f874912aec/matplotlib/matplotlib/issues/30203 |
| og:image:alt | Bug summary matplotlib/lib/matplotlib/axes/_base.py Lines 2054 to 2058 in 5a10e4d if shared_x and shared_y: raise RuntimeError("set_aspect(..., adjustable='datalim') or " "axis('equal') are not all... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | youngjae142 |
| 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