Use imshow of matplotlib.pylab with a python ide?

淺唱寂寞╮ 提交于 2019-11-26 23:35:47

问题


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.


回答1:


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 (i.e., 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.




回答2:


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


来源:https://stackoverflow.com/questions/34742842/use-imshow-of-matplotlib-pylab-with-a-python-ide

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!