Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Displaying image with matplotlib in ipython

How can I display an image imported with numpy package using matplotlib in ipython?

It should be fairly easy with the command

import numpy as np
import matplotlib.pyplot as plt

im = np.array(Image.open('image.jpg'))

plt.imshow(im)

But the image does not show and I just get the output

<matplotlib.image.AxesImage at 0x7fb38e10ff10>
like image 338
cerebrou Avatar asked Feb 24 '16 06:02

cerebrou


1 Answers

You must call plt.show() to actually bring up the windows. You can get around this by using interactive mode. But for scripts it is better to simply call show() after completing all your plotting commands.

like image 198
Hannes Ovrén Avatar answered Oct 13 '22 10:10

Hannes Ovrén