python - 在 ipython 中使用 matplotlib 显示图像

标签 python matplotlib imshow

如何在 ipython 中使用 matplotlib 显示使用 numpy 包导入的图像?

使用命令应该相当容易

import numpy as np
import matplotlib.pyplot as plt

im = np.array(Image.open('image.jpg'))

plt.imshow(im)

但是图像没有显示,我只是得到了输出

<matplotlib.image.AxesImage at 0x7fb38e10ff10>

最佳答案

您必须调用 plt.show() 才能实际调出窗口。 您可以使用交互模式 来解决这个问题。但对于脚本,最好在完成所有绘图命令后简单地调用 show()

关于python - 在 ipython 中使用 matplotlib 显示图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35595307/

相关文章:

python-3.x - 随着地球旋转,对两点之间的点进行动画处理

python - 如何在 Ubuntu 18.04 apache2 服务器 Django 中解决 PermissionError :[Errno13] using Python matplotlib. pyplot.savefig

python - Pandas DataFrame.hist() 不起作用

python - select 语句获取所有相同的记录,但只有一个字段不同

python - 有没有办法限制现有的 TensorFlow 对象检测模型?

python - 在 python (Matplotlib) 中使用子图和 imshow 时删除白色边框

python - 使用 imshow 绘制一行又一行

python - 在 python 中的 imshow 中获取正确的轴标签

python - SQLAlchemy 池连接关闭异常

python - 使用 Pydev(Python 和 Eclipse)进行连续单元测试