Frage

I am using the anaconda distribution of ipython/Qt console. I want to plot things inline so I type the following from the ipython console:

%pylab inline

Next I type the tutorial at (http://pandas.pydata.org/pandas-docs/dev/visualization.html) into 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.

War es hilfreich?

Lösung

Plots are not displayed until you run

plt.show()

Andere Tipps

There could be 2 ways to approach this problem:

1) Either invoke the inline/osx/qt/gtk/gtk3/tk backend. Depends on the ipython console that you have been using. So, simply do:

%matplotlib inline #Here the inline backend is invoked, which removes the necessity of calling show after each plot.

or for ipython/qt console, do:

%matplotlib qt #This one works for me, thus, depends on the ipython console you use.

#

2) Or, do the traditional way as aforementioned (already answered above on this page):

plt.show() #However, you will have to call this show function each time.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top