[英]ipython pandas plot does not show
I am using the anaconda distribution of ipython/Qt console. 我正在使用anaconda分发的ipython / Qt控制台。 I want to plot things inline so I type the following from the ipython console: 我想内联绘制内容,所以我从ipython控制台输入以下内容:
%pylab inline
Next I type the tutorial at ( http://pandas.pydata.org/pandas-docs/dev/visualization.html ) into ipython... 接下来,我将( http://pandas.pydata.org/pandas-docs/dev/visualization.html )的教程输入到ipython中...
import matplotlib.pyplot as plt
import pandas as pd
ts = pd.Series(randn(1000), index = pd.date_range('1/1/2000', periods=1000))
ts = ts.cumsum()
ts.plot()
... and this is all that i get back: ......这就是我回来的全部内容:
<matplotlib.axes.AxesSubplot at 0x109253410>
But there is no plot. 但没有情节。 What could be wrong? 可能有什么不对? Is there another command that I need to supply? 我需要提供另一个命令吗? The tutorial suggests that that is all that I need to type. 教程表明,这就是我需要输入的所有内容。
Plots are not displayed until you run 在运行之前不会显示绘图
plt.show() plt.show()
There could be 2 ways to approach this problem: 有两种方法可以解决这个问题:
1) Either invoke the inline/osx/qt/gtk/gtk3/tk backend. 1)调用内联/ osx / qt / gtk / gtk3 / tk后端。 Depends on the ipython console that you have been using. 取决于您一直使用的ipython控制台。 So, simply do: 所以,只需:
%matplotlib inline
# Here the inline backend is invoked, which removes the necessity of calling show after each plot. %matplotlib inline
# 这里调用内联后端,这消除了在每个绘图后调用show的必要性。
or for ipython/qt console, do: 或者对于ipython / qt控制台,执行:
%matplotlib qt
# This one works for me, thus, depends on the ipython console you use. %matplotlib qt
# 这个适用于我,因此,取决于你使用的ipython控制台。
# #
2) Or, do the traditional way as aforementioned ( already answered above on this page ): 2) 或者,按照前面提到的传统方式 ( 已在本页上面回答 ):
plt.show()
#However, you will have to call this show function each time. plt.show()
#但是,每次都必须调用这个show函数。
用ipython notebook --pylab inline
开始ipython ipython notebook --pylab inline
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.