0

I have been using Cartopy to plot data using 'equal' aspect, resulting in all manner of non-square Axes sizes. These usually look OK in Jupyter notebooks, but when saving the images (or when doing more complicated operations like adding colorbars), the resulting Figures are often huge, with a lot of blank space around the Axes plotting area. They also look bad when using %matplotlib widget. An example is provided below.

Example of image with undesirable padding

It seems that the figure in this case is too big in at least one dimension. I would like to remove that extra space in the final output figure, without shrinking the size of the plotting area itself.

I know that I can adjust the figure size itself with .set_figwidth and .set_figheight, as well as setting figsize= upon creation. But I don't know how to figure out the correct dimensions to shrink the figure without shrinking the axes, and I haven't seen any way to do this automatically. What's the correct solution? I would like to avoid manually editing my images after creating them!

shadowtalker
  • 12,529
  • 3
  • 53
  • 96
  • Maybe this can help https://stackoverflow.com/a/19306776/13636407 – paime Feb 17 '23 at 08:43
  • @paime I think that answers the question, yes! I will try it and post a self-answer if it works. I am sure I am not the first person to have this question, and I never came across the answer you posted after searching for a long time, due to the limited scope of the question it addresses. – shadowtalker Feb 17 '23 at 16:52

0 Answers0