eclipse - 如何让 PyDev 与 MathPlotLib 一起工作?
问题描述
每当我运行此代码时,都会弹出一个窗口并立即消失。Python 解释器已设置好,所有其他命令都可以在控制台和编辑器中运行。我目前正在使用 Eclipse 2019 和 Python 2.7。
将我的代码的最后一行从 fig.show() 更改为 PLT.show() 仅适用于这个程序(我需要一个更强大的解决方案)。为了以防万一,我已将 PyQt4 库安装到 Eclipse/PyDev 中。
'''
Read and show an image.
'''
import PIL
import matplotlib.pyplot as plt
import os.path
import numpy as np # "as" lets us use standard abbreviations
#from PyQt4.Qt import QEventLoop
'''Read the image data'''
# Get the directory of this python script
directory = os.path.dirname(os.path.abspath(__file__))
# Build an absolute filename from directory + filename
filename = os.path.join(directory, 'woman.jpg')
# Read the image data into an array
img = plt.imread(filename)
'''Show the image data'''
# Create figure with 1 subplot
fig, ax = plt.subplots(1, 1)
# Show the image data in a subplot
ax.imshow(img, interpolation='none')
# Show the figure on the screen
fig.show() #changed from fig.show()
没有错误消息,但窗口停留的时间不够长。
解决方案
推荐阅读
- django - 当我开始另一个芹菜工人崩溃时
- firefox-addon - Mozilla Web 扩展中输入类型=“文件”的问题
- html - 有没有办法将 onclick 事件应用于 xslt 中的多个值?
- java - SpaceVim jdt-语言-服务器-最新
- angular - SnackBar 在效果规范文件中
- r - Linear regression on split data in R
- python - 合并两个具有重叠范围的数据框并计算按类别分组的重叠
- python - 在购物 django rest 中按类别过滤品牌
- c# - C# WinForm:单击显示帮助工具提示和 Shift+单击显示管理面板登录?
- c# - 为什么这个异步函数需要一个返回值