简体   繁体   中英

Use imshow of matplotlib.pylab with a python ide?

I tried to run example in photutil

Everything works great except the line

plt.imshow(image, cmap='gray_r', origin='lower')

which does not raise an exception but no image is shown. I use the eric ide.

You need to call plt.show() afterwards.

From the Matplotlib FAQ :

When you want to view your plots on your display, the user interface backend will need to start the GUI mainloop. This is what show() does. It tells matplotlib to raise all of the figure windows created so far and start the mainloop. Because this mainloop is blocking by default (ie, script execution is paused), you should only call this once per script, at the end. Script execution is resumed after the last window is closed.

# need to use matplotlib inline if want to show at jupyter Notebook
%matplotlib inline
plt.imshow(image, cmap='gray_r', origin='lower')
plt.show()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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