0

Ran the following code snippet, it was able to display the shape of the image as follows, but it can't display/plot it.

(48, 48, 4)

Here is the code snippet

import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import numpy as np
import sys

img = mpimg.imread('/Users/joe/Downloads/amazon.png')
print(img.shape)
plt.imshow(img)

for line in sys.stdin:
    print (line)

Wonder what may have gone wrong.

pktCoder
  • 1,105
  • 2
  • 15
  • 32
  • Retracted the answer as its a dupe. The short of it - you put the image in the figure but you are not showing the figure itself: use `plt.show()` after `plt.imshow(img)` Read up in See: [pyplot.imshow()](https://matplotlib.org/api/_as_gen/matplotlib.pyplot.imshow.html) See: [pyplot.show()](https://matplotlib.org/api/_as_gen/matplotlib.pyplot.show.html) – Patrick Artner Feb 10 '18 at 21:34
  • Thanks @patrick-artner, this helps! wish it's in the form of an anwser so I can accept it. Yes, reading docs would be helpful. – pktCoder Feb 10 '18 at 22:08

0 Answers0