user2129468
user2129468

Reputation: 701

imshow() function not working

I'm working on a program in python with packages numpy,scipy and matplotlib.pyplot. This is my code:

import matplotlib.pyplot as plt
from scipy import misc
im=misc.imread("photosAfterAverage/exampleAfterAverage1.jpg")
plt.imshow(im, cmap=plt.cm.gray)

for some reason the image isn't showing up (checked if I got the image, in that part it's all fine- I can print the array.).

Upvotes: 46

Views: 60660

Answers (2)

Remi Cuingnet
Remi Cuingnet

Reputation: 991

"Interactive mode may also be turned on via matplotlib.pyplot.ion(), and turned off via matplotlib.pyplot.ioff()" cf. matplotlib user guide.

Upvotes: 7

tiago
tiago

Reputation: 23492

You need to call plt.show() to display the image. Or use ipython --pylab for an interactive shell that is matplotlib aware.

Upvotes: 77

Related Questions