【发布时间】:2019-07-31 03:10:14
【问题描述】:
我正在使用 matplotlib 和 GridSpec 在 3x3 子图中绘制 9 个图像。
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 中使用它?谢谢
【问题讨论】:
-
看看这个链接对你有没有帮助:stackoverflow.com/questions/13714454/…
标签: python python-3.x matplotlib