Irregular subplots plotting in PyGMT

Hello everyone,

Can pygmt plot such subplots, with a different number of subgraphs per line, with a legend on the right side of each line and annotations on the left side.

Thank you for your help!

Yes it should be possible, see the tutorial at https://www.pygmt.org/v0.9.0/tutorials/advanced/subplots.html. Use with fig.subplot(nrows=4, ncols=4, ...), and then just skip plotting the row/col panels that you don’t have data for. See also https://www.pygmt.org/v0.9.0/gallery/embellishments/colorbars_multiple.html for an example on plotting different colorbars for different panels in a subplot.

1 Like

@weiji14, Thank you very much for the reply, which is quite useful!

Reviving this. Guys, do you manage to do subplots with colorbars in each panel?

I can’t in GMT.jl and the failure is strange. At the PS level it seems that the origin is always reset before the gmt colorbar call and hence the multiple colorbars overlap on top of first one.

I think I had a similar problem a while ago and I solved it by specifying the region and projection (-R and -J) in the colorbar.

gmt inset begin -R105.2W/104.6W/4.75S/4.4S -JM3i -DJLB+o-5.25i/0.4i -F+gwhite+p0.5p,black -N
gmt makecpt -Chaxby -T-5000/-2000 -H > haxby.cpt
gmt basemap -Bpxa0.2 -Bpya0.1 -LjLT+o0.2+w10k+l"Scale (km)" -BSEnw \
            --MAP_FRAME_TYPE=inside --MAP_FRAME_AXES=eslt --FORMAT_GEO_MAP=ddd.x
gmt colorbar -Chaxby.cpt -DJCB+w2.6i/0.1i+o0.0i/0.25i+h+ml -Bxa1000f250+l"Bathymetry Depth" -By+lm -Vd -R105.2W/104.6W/4.75S/4.4S -JM3i
rm -f haxby.cpt
gmt inset end

If you do not specify -R and -J in gmt colorbar, then the colorbar scale plots out of alignment.

Thanks, but the case I’m referring to is different. It’s some convoluted missing set occurring when calling GMT from externals (Julia/Matlab in this case) to make subplots figures.