Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/299.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用子图()在网格中显示多个图像_Python_Image_Matplotlib - Fatal编程技术网

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)