简体   繁体   English

绘制几个图中的图片列表

[英]Plotting list of picturelists in several plots

I'v got a list with picture-path's and i want to "plot" them in several plots eg: 我有一个带有图片路径的列表,我想在几个图中“绘制”它们,例如:

list = [['./path1/pic1.jpg','./path1/pic2.jpg',...],['./path2/pic1.jpg',...],[...]]

the output has to be in this eg 3 plots with the pictures from the list's 输出必须在这个例如3个图中,列表中的图片

i've tried that way but it seems to be not right because i get this Error 我试过这种方式,但似乎不对,因为我得到这个错误

    fig, ax = plt.subplots(len(list))
    for image in list:
        im = Image.open(image)
        ax.imshow(im)


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

I also tried im = mpimg.imread(image) which gaves me the same result and ax.imshow(image) without any "opening" 我也尝试了im = mpimg.imread(image) ,它给了我相同的结果和ax.imshow(image)没有任何“开放”

maybe someone know how do do this... 也许有人知道怎么做...

subplots function returns a ndarray of axes. subplots函数返回一个ndarray轴。 It's length will be the same as the number of subplots you created. 它的长度将与您创建的子图的数量相同。 So you have to index it and show the image on the right one. 因此,您必须将其编入索引并在右侧显示图像。

images = [...]
fig, axes = plt.subplots(len(images))
for i, image in enumerate(images):
    im = Image.open(image)
    axes[i].imshow(im)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM