我试图使用for lop来填充子批次,但我不能这样做。以下是我的代码摘要: 编辑1:
for idx in range(8):
img = f[img_set[ind[idx]][0]]
patch = img[:,col1+1:col2, row1+1:row2]
if idx < 3:
axarr[0,idx] = plt.imshow(patch)
elif idx <6:
axarr[1,idx-3] = plt.imshow(patch)
else:
axarr[2,idx-6] = plt.imshow(patch)
path_ = 'plots/test' + str(k) + '.pdf'
fig.savefig(path_)
它只在第三行和第三列打印图像,其余部分为空白。我怎样才能改变?
你忘记创建子图了。您可以使用
add_subplot()
(http://matplotlib.org/api/figure_api.html#matplotlib.figure.Figure.add_subplot)。例如在你的例子中,可能是这样的:
相关问题 更多 >
编程相关推荐