-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
imshow() subplots with shared axes generate unwanted white spaces #1789
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi @mlynn1 - it looks like sharing forces the aspect ratio to be equal. As you say, setting the aspect to 'auto' stretches the image. The only other behaviour I can come up with is being able to reduce the size of the actual Axes itself. Is that what you had in mind? As far as I'm aware, there is no such functionality to do that automatically. Thanks, |
I guess what I don't understand is why Yes, I could manually set axes positions and sizes with |
Only if the black y axis lines moved inwards to be tight against the image boundary. (unless I've misunderstood you). That was the bit that I don't know whether it is possible - I've never seen it done, though I'm no expert in this. I believe these are your options:
I'm struggling to see any other way of arranging the plot (be it in matplotlib, or by pen and paper). Sorry if I'm missing something obvious. Cheers, |
I tried your first three suggestions above, and while the amount of white space is reduced, it is still there. And there are times when one would like an unstretched image...
I don't know why this is not done automatically by Basically, if I do not add the |
On Wed, Feb 27, 2013 at 4:46 PM, mlynn1 [email protected] wrote:
|
@mlynn1 - thanks I now know what you're after (the behaviour before vs after of the share definition was the key).
When I do this, I get the same behaviour as when not sharing, only with the nice functionality that sharing adds. HTH |
[had a long comment about what I thought was going on, that is now irrelevant] |
@WeatherGod, no it is not a bug. @pelson has the right solution. Sharing and adjustable 'box' are not always compatible. |
@pelson: Thank you for your solution and time! |
I had a similar issue and been searching first about the reason (really couldn't know why), and got here while searching for a solution. However, the solutions was by using the |
This is fixed by #10033. |
When plotting two (or more) subplots which share the same axes, I see large areas of white spaces within the plots as seen here:

These white spaces persist even after
autoscale(False)
,ax.set_xlim(0, 10)
, and/orax.set_xbound(0, 10)
. One way to get rid of the white spaces is to setaspect=auto
inimshow()
, but this is not always ideal.One could also set a
figsize
and manually adjust the axes to get the image contained exactly within the figure without white spaces, but resizing the figure would make the white spaces appear again.Is there a way to correct for this behaviour?
The text was updated successfully, but these errors were encountered: