问题描述
我尝试在 photutil 中运行示例/p>
一切都很好,除了这条线
plt.imshow(image, cmap='gray_r', origin='lower')
不会引发异常但不显示图像.我用的是 eric ide.
之后需要调用plt.show()
.
来自 Matplotlib 常见问题解答:
<块引用>当您想在显示器上查看绘图时,用户界面后端需要启动 GUI 主循环.这就是 show() 所做的.它告诉 matplotlib 提升到目前为止创建的所有图形窗口并启动主循环.因为这个主循环默认是阻塞的(即脚本执行被暂停),你应该只在每个脚本最后调用一次.关闭最后一个窗口后恢复脚本执行.
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 (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.
这篇关于将 matplotlib.pylab 的 imshow 与 python ide 一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!