我正在使用matplotlib和GridSpec在3x3子图中绘制9张图片。
然而,每一行的图像尺寸都不同。例如,第一行的图像尺寸为256x256,第二行的图像尺寸为200x200,第三行的图像尺寸为128x128。
我想在子图中绘制具有相同尺寸的图像。在Python中应该如何使用它?
这是一个4x3子图的示例。
fig = plt.figure(figsize=(30,40))
fig.patch.set_facecolor('white')
gs1 = gridspec.GridSpec(3,3)
gs1.update(wspace=0.05, hspace=0.05)
ax1 = plt.subplot(gs1[0])
ax2 = plt.subplot(gs1[1])
ax3 = plt.subplot(gs1[2])
ax4 = plt.subplot(gs1[3])
ax5 = plt.subplot(gs1[4])
ax6 = plt.subplot(gs1[5])
ax7 = plt.subplot(gs1[6])
ax8 = plt.subplot(gs1[7])
ax9 = plt.subplot(gs1[8])
ax1.imshow(img1,cmap='gray')
ax2.imshow(img2,cmap='gray')
...
ax9.imshow(img9,cmap='gray')
然而,每一行的图像尺寸都不同。例如,第一行的图像尺寸为256x256,第二行的图像尺寸为200x200,第三行的图像尺寸为128x128。
我想在子图中绘制具有相同尺寸的图像。在Python中应该如何使用它?
这是一个4x3子图的示例。