问题:在Ipython notebook / Jupyter中,Pandas未显示我尝试绘制的图形

我正在尝试使用Ipython Notebook中的熊猫绘制一些数据,尽管它给了我对象,但实际上并没有绘制图形本身。所以看起来像这样:

In [7]:

pledge.Amount.plot()

Out[7]:

<matplotlib.axes.AxesSubplot at 0x9397c6c>

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

I am trying to plot some data using pandas in Ipython Notebook, and while it gives me the object, it doesn’t actually plot the graph itself. So it looks like this:

In [7]:

pledge.Amount.plot()

Out[7]:

<matplotlib.axes.AxesSubplot at 0x9397c6c>

The graph should follow after that, but it simply doesn’t appear. I have imported matplotlib, so that’s not the problem. Is there any other module I need to import?


回答 0

请注意,–pylab已被弃用,并且已从较新的IPython版本中删除。建议在IPython Notebook中启用内联绘图的方法现已运行:

%matplotlib inline
import matplotlib.pyplot as plt

有关更多详细信息,请参阅ipython-dev邮件列表中的这篇文章

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.


回答 1

编辑:Pylab已被弃用,请参阅当前接受的答案

好的,看来答案是使用–pylab = inline启动ipython Notebook。因此,ipython notebook –pylab = inline可以完成我之前看到的以及我想要它做的事情。对不起这个原始的问题。

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.


回答 2

与您import matplotlib.pyplot as plt只需添加

plt.show()

它将显示所有存储的图。

With your import matplotlib.pyplot as plt just add

plt.show()

and it will show all stored plots.


回答 3

导入matplotlib之后很简单,如果像这样启动ipython,就可以执行一个魔术

ipython notebook 

%matplotlib 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


回答 4

使用来启动ipython ipython notebook --pylab inline,然后图形将内联显示。

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


回答 5

import matplotlib as plt
%matplotlib as inline
import matplotlib as plt
%matplotlib as inline

回答 6

您需要做的就是导入 matplotlib。

import matplotlib.pyplot as plt 

All you need to do is to import matplotlib.

import matplotlib.pyplot as plt 

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。