在 Ipython 笔记本/木星中,熊猫没有显示我试图绘制的图表

我试图用 Ipython Notebook 的熊猫绘制一些数据,虽然它给了我一个物体,但它并没有真正绘制出图形本身。看起来是这样的:

In [7]:


pledge.Amount.plot()


Out[7]:


<matplotlib.axes.AxesSubplot at 0x9397c6c>

之后应该会出现图表,但它就是不出现。我已经导入了 matplotlib,所以这不是问题。还有其他模块需要导入吗?

86072 次浏览

With your import matplotlib.pyplot as plt just add

plt.show()

and it will show all stored plots.

Edit:Pylab has been deprecated please see the current accepted answer

Ok, It seems the answer is to start ipython notebook with --pylab=inline. so ipython notebook --pylab=inline This has it do what I saw earlier and what I wanted it to do. Sorry about the vague original question.

Note that --pylab is deprecated and has been removed from newer builds of IPython, The recommended way to enable inline plotting in the IPython Notebook is now to run:

%matplotlib inline
import matplotlib.pyplot as plt

See this post from the ipython-dev mailing list for more details.

start ipython with ipython notebook --pylab inline ,then graph will show inline.

simple after importing the matplotlib you have execute one magic if you have started the ipython as like this

ipython notebook


%matplotlib inline

run this command everything will be shown perfectly

All you need to do is to import matplotlib.

import matplotlib.pyplot as plt
import matplotlib as plt
%matplotlib as inline