I often make series of subplots with mpl_toolkits.basemap.Basemap
projections, which generates geographic projections on axes with fixed aspect ratios. When I use fig.tight_layout()
, this adjusts only the axes to be tight inside the bounding figure window -- so if the axes aren't allowed to have changed aspect ratios, this will often leave huge amounts of whitespace -- note this cannot be fixed by using bbox_inches='tight'
in figsave()
, because e.g. 2x2 networks of fixed-AR subplots will have extra interior whitespace.
Here's an example, where each axis has aspect 1:
Is there a way I can adjust the figure to be tight around the inner axes objects? Note this method would necessarily eliminate extra interior whitespace -- fixed-aspect ratio axes are centered in their GridSpec
zone (e.g. the lower-right quadrant) until the total figure height/width is such that the aspect ratio of their GridSpec
zone matches the axes aspect ratio.
Ideally, this method should work for the "outer bounding box" of each axes including its labels, titles, etc, rather than the box itself. One way would be to retrieve the aspect ratios of each subplot and adjust figsize
accordingly, but that leaves the problem of room for titles, ticklabels, etc.; we really want the outer-bounding box aspect ratios.