Python 使用子图()在网格中显示多个图像
我尝试使用Python 使用子图()在网格中显示多个图像,python,image,matplotlib,Python,Image,Matplotlib,我尝试使用plt.subplot()在6 x 5网格中显示30幅图像,我还想用j值标记每个单独的绘图。然而,当我尝试在jupyter笔记本中运行我的代码时,我得到了这个输出(因为某些原因,堆栈不允许我添加图像,所以这里是到输出的img的链接): 我的代码: plt.figure() f, axarr = plt.subplots(5,6) for i in range(5): for j in range(6): axarr[j].imshow(vectors[i]
plt.subplot()
在6 x 5网格中显示30幅图像,我还想用j值标记每个单独的绘图。然而,当我尝试在jupyter笔记本中运行我的代码时,我得到了这个输出(因为某些原因,堆栈不允许我添加图像,所以这里是到输出的img的链接):
我的代码:
plt.figure()
f, axarr = plt.subplots(5,6)
for i in range(5):
for j in range(6):
axarr[j].imshow(vectors[i][j])
axarr[j].title(j)
AttributeError:'numpy.ndarray'对象没有属性'imshow'
指向以下行:
axarr[j].imshow(向量[i][j])
如何使输出在6 x 5的网格中包含间隔良好的图像?
axarr
是一个轴的2D数组,因此axarr[j]
是一个(轴的)1D numpy数组
尝试:
这有点帮助,但现在我得到了一个“Text”对象是不可调用的错误,用于标题line@ArtemisCode7更新后,它应该是
set\u title
而不是title
。
plt.figure()
f, axarr = plt.subplots(5,6)
for i in range(5):
for j in range(6):
axarr[i,j].imshow(vectors[i][j])
axarr[i,j].set_title(j)