避免< matplotlib.figure.Figure at 0xeafea58> [英] Avoiding <matplotlib.figure.Figure at 0xeafea58>
本文介绍了避免< matplotlib.figure.Figure at 0xeafea58>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在同一张图上绘制一系列函数.该代码似乎可以正常运行,但是没有图像出来.只是
I am trying to plot a series of functions on the same graphs. The code seems to run ok, but there is no picture coming coming out. just simply
<matplotlib.figure.Figure at 0xeafea58>
如何解决?
推荐答案
在IPython控制台中,确保图形显示(不显式调用plt.show()
)的最佳方法是使用%matplotlib
模式.如果正确安装了matplotlib,它将自动为您的系统选择合适的后端.
In the IPython console, the best way to make sure figures show up (without explicitly calling plt.show()
) is to use %matplotlib
mode. If matplotlib is installed correctly, it should automatically choose a suitable backend for your system.
例如:
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>]
每个会话中只需输入一次%matplotlib
magic命令.
The %matplotlib
magic command only needs to be entered once per session.
这篇关于避免< matplotlib.figure.Figure at 0xeafea58>的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文