Lower portion of figure cut off

I’m using PyGMT in Jupyter Notebook.

My figures – both in the Jupyter Notebook (“fig.show()”) and the saved .png (“fig.savefig(png_file)”) – get cut off towards the bottom.

My general process is:

[1] Set the figure width:
>> fig_width = 20
>> xsize = fig_width

[2] Calculate the figure height:
>> ysize = xsize * ( (region[3] - region[2])/(region[1] - region[0]) )

[3] Set the projection:
>> projection = ‘X{}c/{}c’.format(xsize, ysize)

I usually have a series of maps and charts on a single figure. Invariably the bottom few cm of the final figure is chopped off, so I reduce “fig_width” by trial-and-error until it all fits.

But there are a couple of issues with this:

  • the lower I go, the lower the resolution of the final image
  • I have to reduce FONT and MAP_FRAME_PEN configurations to make things scale
    >> pygmt.config(FONT=‘6,Helvetica,black’)
    >> pygmt.config(MAP_FRAME_PEN=‘0.2p,black’)

I’ve tried increasing the paper size and increasing the resolution:
>> pygmt.config(PS_MEDIA=‘a0’)
>> pygmt.config(GMT_GRAPHICS_DPU=‘600i’)
but neither seems to work.

I’d appreciate advice!

Have you try to move your whole figure upwards in the paper? Something like -Y4c to move your figure 4 cm upwards in paper.

1 Like

Thank you!

You got me on the right path. I was adding subplots from top-to-bottom (with negative yshift values). If I add subplots from bottom-to-top (with positive yshift values), the figures are no longer clipped.

FYI this limitation will be fixed with the release of GMT 6.4.0 which allows more room for adding subplots top-to-bottom (https://github.com/GenericMappingTools/gmt/pull/6247).

1 Like