Plotting images side by side using matplotlib

后端 未结 5 1118
难免孤独
难免孤独 2020-12-23 09:36

I was wondering how I am able to plot images side by side using matplotlib for example something like this:

The closest I got is this:

5条回答
  •  清酒与你
    2020-12-23 09:58

    If the images are in an array and you want to iterate through each element and print it, you can write the code as follows:

    plt.figure(figsize=(10,10)) # specifying the overall grid size
    
    for i in range(25):
        plt.subplot(5,5,i+1)    # the number of images in the grid is 5*5 (25)
        plt.imshow(the_array[i])
    
    plt.show()
    

    Also note that I used subplot and not subplots. They're both different

提交回复
热议问题