带有matshow的matplotlib子图

时间:2019-02-18 18:01:16

标签: matplotlib subplot

使用matshow时,我可以成功地对多个图像进行子绘图:

fig, axes = plt.subplots(nrows=1, ncols=4)
axes[0].matshow(img_tensors, cmap='jet')
axes[0].set_title("Original Image")
axes[1].matshow(activation0[0,:,:,0], cmap='jet')
axes[1].set_title("First Activation")
axes[2].matshow(activation1[0,:,:,0], cmap='jet')
axes[2].set_title("Second Activation")
axes[3].matshow(activation2[0,:,:,0], cmap='jet')
axes[3].set_title("Third Activation")
plt.show()

enter image description here

上面是输出。但是,如果我尝试将其更改为2x2图像数组(即nrows = 2,ncols = 2),则会出现以下错误:

AttributeError: 'numpy.ndarray' object has no attribute 'matshow'

为什么它挂在2x2上,如何解决?

0 个答案:

没有答案