PyGMT: How to automatically set figure size for subplots?

I have a couple of plots that are rectangles rather than squares, with a figure length/width automatically determined by PyGMT. I would like to instead plot these side by side using fig.subplot, but the function requires the figsize parameter which asks for a length/width and I don’t know what the appropriate length and width are. Of particular concern for me is that when I enter different length/width values into figsize, the frame around each plot changes sizes with figsize while the plots appear not to. Is there a way to let PyGMT automatically determine the appropriate length and width for figsize?

Hi @hazardgoat, are you plotting a Geographic map (i.e. longitude/latitude coordinates) or a Cartesian map (e.g. UTM x and y)? Instead of specifying figsize (which is for the entire figure), you can also choose to set subsize (which is for each individual subplot) in PyGMT’s fig.subplot function.

If you happen to be plotting a Geographic map, I think there is a way to just set the width, and the height will be calculated automatically according to the documentation for subsize (-Fs) at It’s a bit hard to explain though without looking at your code, maybe if you can share an example then we can advise better.

1 Like

Thank you! I’m plotting a geographic map and this is almost exactly what I wanted. It appears that subsize can only determine figure height automatically by setting region and projection in fig.subplot, so I still had to play around with the width. However, it was much easier to dial in than before!