Stream: python-questions

Topic: ✔ figsize does not work in subplot argument


view this post on Zulip Mira Berdahl (Jan 13 2023 at 20:13):

Hi,
When I try to change the figsize in the below script, it does not change the size of my figure. Any ideas what is going on? Interestingly, if I include colorbars, the colorbars change size, but the maps do not.

fig, axs = plt.subplots(1,3, figsize = (26,10), subplot_kw=dict(projection=ccrs.Robinson()))

axs[0].coastlines(lw=0.2)
p = axs[0].pcolormesh(grid.TLONG,
              grid.TLAT,
              HC_127kaControl_Clim.HeatContent,
              transform=ccrs.PlateCarree(),
              vmin=0, vmax=7e12, cmap='gist_heat_r')

p1 = axs[1].pcolormesh(grid.TLONG,
              grid.TLAT,
              HC_PIControl_Clim.HeatContent,
              transform=ccrs.PlateCarree(),
              vmin=0, vmax=7e12, cmap='gist_heat_r')

p2 = axs[2].pcolormesh(grid.TLONG,
              grid.TLAT,
              (HC_127kaControl_Clim - HC_PIControl_Clim).HeatContent,
              transform=ccrs.PlateCarree(),
              vmin=-1.5e10, vmax=1.5e10, cmap='RdBu_r')

plt.tight_layout()

axs[0].set_title('127ka Control' ,fontsize = 18)
axs[1].set_title('PI Control' ,fontsize = 18)
axs[2].set_title('127 ka - PI Control' ,fontsize = 18)

land = axs[0].add_feature(cartopy.feature.NaturalEarthFeature('physical', 'land', '110m',linewidth=0.5, edgecolor='black', facecolor='darkgray'))
land = axs[1].add_feature(cartopy.feature.NaturalEarthFeature('physical', 'land', '110m',linewidth=0.5, edgecolor='black', facecolor='darkgray'))
land = axs[2].add_feature(cartopy.feature.NaturalEarthFeature('physical', 'land', '110m',linewidth=0.5, edgecolor='black', facecolor='darkgray'))

view this post on Zulip David Ahijevych (Jan 18 2023 at 20:03):

Hi Mira,
I copied and pasted your code into Jupyterlab and added a simple fake dataset. While changing figsize did not affect the figure size in the notebook, it did affect the output image size if I used the savefig method, i.e. fig.savefig().

view this post on Zulip Mira Berdahl (Jan 19 2023 at 18:31):

David Ahijevych said:

Hi Mira,
I copied and pasted your code into Jupyterlab and added a simple fake dataset. While changing figsize did not affect the figure size in the notebook, it did affect the output image size if I used the savefig method, i.e. fig.savefig().

Aaah, ok good to know! Thanks for your help @David Ahijevych

view this post on Zulip Notification Bot (Jan 19 2023 at 18:39):

Deepak Cherian has marked this topic as resolved.


Last updated: May 16 2025 at 17:14 UTC