Color bar for each row in ImageGrid

Disclaimer: I am very inexperienced using matplotlib and python in general.

Here's the figure I'm trying to make:

almost complete figure

Using GridSpec

it works well for highlighting graphs, but when I try to include a colored bar to the right of each row, it resizes the corresponding subheading. This seems to be a well-known and inevitable problem with GridSpec

. So on the advice of this question: Matplotlib 2 Subplots, 1 Colorbar I decided to redo the whole plot using ImageGrid

. Unfortunately, the documentation only lists options cbar_mode=[None|single|each]

, whereas I want 1 colobar per line. Is there a way to do this inside one ImageGrid

? or I'll have to do 2 grids and deal with the alignment nightmare.

How about the fifth plot below? Is there some way to incorporate this into the image grid?

The only way to see how this works is to somehow nest two ImageGrid

in GridSpec

in a 1x3 column. it seems overly complicated and difficult, so I don't want to create this script until I know its correct path.

Thanks for any help / advice!

+3


source to share


1 answer


Ok I figured it out. It seems to be ImageGrid

using subplot

somehow inside it. So I was able to create the following plot using something like

TopGrid = ImageGrid( fig, 311,
                nrows_ncols=(1,2),
                axes_pad=0,
                share_all=True,
                cbar_location="right",
                cbar_mode="single",
                cbar_size="3%",
                cbar_pad=0.0,
                cbar_set_cax=True
                )  
<Plotting commands for the top row of plots and colorbar>

BotGrid = ImageGrid( fig, 312,
                nrows_ncols=(1,2),
                axes_pad=0,
                share_all=True,
                cbar_location="right",
                cbar_mode="single",
                cbar_size="3%",
                cbar_pad=0.0,
                )
<Plotting commands for bottom row . . .>
StemPlot = plt.subplot(313)
<plotting commands for bottom stem plot>

      



EDIT: Gaps in color plots are intentional, not some artifacts from adding color bars

+2


source







All Articles