1、创建3行1列子图,其中在第二个子图再绘制3行10列子图
#figure configuration
fig=plt.figure(figsize=(17/2.54, 22/2.54),dpi=300)
gs = GridSpec(3, 1, width_ratios=[1], height_ratios=[6.5, 9.5, 4.5], wspace=0.2, hspace=0.2, figure=fig)
第一个子图:
ax1 = fig.add_subplot(gs[0, :],projection=ccrs.PlateCarree())#default:等距离投影
# # ax1.set_position(gs[0, 0].get_position(fig))
第二个子图:
ax2 = fig.add_subplot(gs[1, :])
# # ax2.set_position(gs[1, 0].get_position(fig))
第二个子图上再添加子图:
# 创建GridSpec以将ax2分成3行10列的子图
gs2 = gridspec.GridSpecFromSubplotSpec(3, 10, subplot_spec=ax2)
for row in range(3):
for col in range(10):
ax = plt.subplot(gs2[row, col])
ax.set_title(f'Subplot 2-{row+1}-{col+1}')
第三个子图:
# ax3 = fig.add_subplot(gs[1, 1])
# # ax3.set_position(gs[1, 1].get_position(fig))