raiseRuntimeError("set_aspect(..., adjustable='datalim') or "
"axis('equal') are not allowed when both axes "
"are shared. Try set_aspect(..., "
"adjustable='box').")
This part is a strong regulation.
People would like to share both x and y axes when setting the aspect ratio to a certain value.
Though there will be a conflict in datalim between subplots, it is a minor problem to me.
When I changed this part as below, it worked like a charm as I expected.
File "/home/ssrokyz/app/miniforge3/lib/python3.12/site-packages/matplotlib/backends/backend_qt.py", line 508, in _draw_idle
self.draw()
File "/home/ssrokyz/app/miniforge3/lib/python3.12/site-packages/matplotlib/backends/backend_agg.py", line 382, in draw
self.figure.draw(self.renderer)
File "/home/ssrokyz/app/miniforge3/lib/python3.12/site-packages/matplotlib/artist.py", line 94, in draw_wrapper
result = draw(artist, renderer, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ssrokyz/app/miniforge3/lib/python3.12/site-packages/matplotlib/artist.py", line 71, in draw_wrapper
return draw(artist, renderer)
^^^^^^^^^^^^^^^^^^^^^^
File "/home/ssrokyz/app/miniforge3/lib/python3.12/site-packages/matplotlib/figure.py", line 3246, in draw
artists = self._get_draw_artists(renderer)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ssrokyz/app/miniforge3/lib/python3.12/site-packages/matplotlib/figure.py", line 166, in _get_draw_artists
ax.apply_aspect(locator(ax, renderer) if locator else None)
File "/home/ssrokyz/app/miniforge3/lib/python3.12/site-packages/matplotlib/axes/_base.py", line 2061, in apply_aspect
raise RuntimeError("set_aspect(..., adjustable='datalim') or "
RuntimeError: set_aspect(..., adjustable='datalim') or axis('equal') are not allowed when both axes are shared. Try set_aspect(..., adjustable='box').
Thanks for pointing @oscargus
Yes. I actually came from that thread.
My opinion is that it seems like a strong regulation.
Why don't we make it just a warning, but an error?
Or why can't we enable it with an optional parameter?
IIRC there’s nothing against this from a conceptual point of view. It’s just not implemented. Note that adjustable datalims coordinate y and y limits on anAxes. Sharing coordinates x (or y) limits across multiple Axes. These are separate and simple code paths. For both to work simultaneously, one needs to implement a holistic coordination of all x and y axes.
Thanks for the explanation @timhoffm
I will be very happy if it is implemented someday, but I think disabling it until the actual implementation seems unnecessary.
I mean, it has not been implemented for 7 years now.
I think this feature is a really basic thing people would do, even though it doesn't work perfectly.
I do not follow. If the scenario is not implemented and we do not raise what do you expect to happen? - It's clearly not what the user has requested. Some of the requirements sharing and aspects with adjustable datalims will not be met. In that case it's better to deny the action and let the user choose what to give up.
raiseRuntimeError("set_aspect(..., adjustable='datalim') or "
"axis('equal') are not allowed when both axes "
"are shared. Try set_aspect(..., "
"adjustable='box').")
In other words, I cannot get that figure unless I change the code.
When I giveup the set_aspect(..., adjustable='datalim') and set it as set_aspect(..., adjustable='box'), what I get is below.
which is not what I want to get.
Activity
oscargus commented on Jun 22, 2025
Here is a bit of back story:
#10033
#11416 especially #11416 (comment)
youngjae142 commented on Jun 23, 2025
Thanks for pointing @oscargus
Yes. I actually came from that thread.
My opinion is that it seems like a strong regulation.
Why don't we make it just a warning, but an error?
Or why can't we enable it with an optional parameter?
timhoffm commented on Jun 24, 2025
IIRC there’s nothing against this from a conceptual point of view. It’s just not implemented. Note that adjustable datalims coordinate y and y limits on anAxes. Sharing coordinates x (or y) limits across multiple Axes. These are separate and simple code paths. For both to work simultaneously, one needs to implement a holistic coordination of all x and y axes.
youngjae142 commented on Jun 25, 2025
Thanks for the explanation @timhoffm
I will be very happy if it is implemented someday, but I think disabling it until the actual implementation seems unnecessary.
I mean, it has not been implemented for 7 years now.
I think this feature is a really basic thing people would do, even though it doesn't work perfectly.
timhoffm commented on Jun 25, 2025
I do not follow. If the scenario is not implemented and we do not raise what do you expect to happen? - It's clearly not what the user has requested. Some of the requirements sharing and aspects with adjustable datalims will not be met. In that case it's better to deny the action and let the user choose what to give up.
rcomer commented on Jun 26, 2025
I cannot reproduce the error with the provided code example. I can if I remove (one of) the calls to set_box_aspect.
Edit: the fixed box aspect seems to make the datalim adjustment redundant, so we return early here:
matplotlib/lib/matplotlib/axes/_base.py
Lines 2030 to 2033 in 5a10e4d
youngjae142 commented on Jun 26, 2025
@rcomer Thanks for pointing that out.
I am not sure why I missed that.
I changed the code
from
to
to raise the error.
youngjae142 commented on Jun 26, 2025
@timhoffm What I expect to happen is exactly what I plotted in "Expected outcome."
I can get the figure only when I rule out this code block.
matplotlib/lib/matplotlib/axes/_base.py
Lines 2054 to 2058 in 5a10e4d
In other words, I cannot get that figure unless I change the code.
When I giveup the set_aspect(..., adjustable='datalim') and set it as set_aspect(..., adjustable='box'), what I get is below.

which is not what I want to get.
rcomer commented on Jun 26, 2025
Removing the error block does allow the specific updated example to work, but if we swap the x- and y-values, we get empty axes:
youngjae142 commented on Jun 27, 2025
@rcomer
I see. Now I see the problem a bit. Thanks.
In that case,
Changing this code
matplotlib/lib/matplotlib/axes/_base.py
Lines 2054 to 2058 in 5a10e4d
to this
works.
oscargus commented on Jun 27, 2025
But in the last example, the aspect is not 1?
youngjae142 commented on Jun 30, 2025
I see.
So now I get it that some parts need to be implemented to make it work.