简体   繁体   English

在python IDE中使用matplotlib.pylab的imshow吗?

[英]Use imshow of matplotlib.pylab with a python ide?

I tried to run example in photutil 我试图在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. 之后,您需要调用plt.show()

From the Matplotlib FAQ : Matplotlib常见问题解答

When you want to view your plots on your display, the user interface backend will need to start the GUI mainloop. 当您想在显示器上查看绘图时,用户界面后端将需要启动GUI主循环。 This is what show() does. 这就是show()所做的。 It tells matplotlib to raise all of the figure windows created so far and start the mainloop. 它告诉matplotlib提升到目前为止创建的所有图形窗口并启动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()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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