[Matplotlib-users] plot with multiple images and colorbar

Jody Klymak jklymak at uvic.ca
Tue May 14 12:02:19 EDT 2019

Hi Jonathan, 

If you are setting the aspect ratio of your subplots, space can be missing on the RHS if the setting the aspect ratio causes the subplots to shrink horizontally.  The “solution” to this is to make your *figure* more tall and less wide until the aspect ratio shrink happens in the vertical instead of the horizontal, or don’t set the aspect ratio.  Its pretty hard for matplotlib to do this automatically and still do the usual layout for axes that do not have their aspect ratio set, the desired behaviour of which is to make the axes as big as possible.

I’m working on a PR to make colorbars automatically match the height of the shown axes, rather than its place holder, but thats non-trivial. 

Cheers,  Jody

> On 14 May 2019, at 08:43, Slavin, Jonathan <jslavin at cfa.harvard.edu> wrote:
> Hi,
> I've been working on producing a figure using results of a hydro simulation at multiple times. Because the scale of the region of interest changes over time, I want the size of the axes to change. My goal is to make a figure with results of four timesteps, so four images in a row, with each scaled appropriately and with a colorbar on the right. I tried to use ImageGrid, but that doesn't like having different axis scales for the plots - at least it seems to always scale the y axis the same despite my best efforts - though it does a nice job of locating the colorbar.
> So I went back to subplots, but in that case the colorbar isn't the right size, at least without tweaking the shrink parameter. Also, for some reason there is a lot of space on the right of the plot even when I use subplots_adjust to set right=0.99. There are many ways to place colorbars, I know, but it would seem that my case would not be so unusual that I should need such complex methods to do what I want. Maybe I'm missing something. Any advice would be appreciated.
> Regards,
> Jon
> -- 
> Jonathan D. Slavin
> Astrophysicist - High Energy Astrophysics Division
> Center for Astrophysics | Harvard & Smithsonian
> Office: (617) 496-7981 | Cell: (781) 363-0035
> 60 Garden Street | MS 83 | Cambridge, MA 02138
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users at python.org
> https://mail.python.org/mailman/listinfo/matplotlib-users

Jody Klymak    

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20190514/919b26f9/attachment.html>

More information about the Matplotlib-users mailing list