Use imshow of matplotlib.pylab with a python ide?(将 matplotlib.pylab 的 imshow 与 python ide 一起使用?)
问题描述
我尝试在 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 一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:将 matplotlib.pylab 的 imshow 与 python ide 一起使用?
基础教程推荐
- pyserial - 可以从线程 a 写入串行端口,是否阻塞从线程 b 读取? 2022-01-01
- numpy float:比算术运算中内置的慢 10 倍? 2022-01-01
- Discord.py 缺少必需的参数 2022-01-01
- 在 Celery 工作人员中捕获 Heroku SIGTERM 以优雅地关 2022-01-01
- 由Python将MP3转换为MIDI(类型错误:无法加载插件:mtg-Melodia:Melodia) 2022-01-01
- 与常规 dict 相比,Python manager.dict() 非常慢 2022-01-01
- 尝试制作WhatsApp机器人 2022-01-01
- 将 x 轴刻度更改为自定义字符串 2022-01-01
- 用 Python 编写 Fortran 无格式文件 2022-01-01
- 使用生成器和迭代器时 Python 多循环失败 2022-01-01
