image - 避免 <matplotlib.figure.Figure at 0xeafea58>

标签 image matplotlib plot graphics

我试图在同一张图上绘制一系列函数。代码似乎运行正常,但是没有图片出来。只是简单的

<matplotlib.figure.Figure at 0xeafea58>

如何修复?

最佳答案

在 IPython 控制台中,确保图形显示(无需显式调用 plt.show())的最佳方法是使用 %matplotlib 模式。如果 matplotlib 安装正确,它应该会自动为您的系统选择合适的后端。

例如:

In [1]: import matplotlib.pyplot as plt

In [2]: plt.plot([1, 2, 3])  # no plot shown!
Out[2]: [<matplotlib.lines.Line2D at 0x110eac898>]

In [3]: %matplotlib
Using matplotlib backend: MacOSX

In [4]: plt.plot([1, 2, 3])  # plot shown now
Out[4]: [<matplotlib.lines.Line2D at 0x112174400>]

enter image description here

%matplotlib 魔术命令每个 session 只需输入一次。

关于image - 避免 <matplotlib.figure.Figure at 0xeafea58>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43504109/

相关文章:

C# 无法显示具有正确颜色映射的 RAW16 灰度图像

matplotlib - 是否支持cloud9 ide和matplotlib或其他适用于python的图形工具?

python - **凹**非网格数据的matplotlib轮廓/轮廓

R 需要重新启动 RStudio 以使用 dev.copy() 和 dev.off() 查看并保存在文件中

python - Django 不通过/media/显示图像

c++ - 写入 .PGM 图像会导致形状困惑

python - 为图像中的不同生物细胞分配不同的颜色

python - Matplotlib - 在具有值 z 的线上标记点 (x,y)

python - matplotlib:我可以创建 AxesSubplot 对象,然后将它们添加到 Figure 实例吗?

matlab - 在 MATLAB 中绘制除数 MLP 线和图表