24

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.

9
  • 1
    When you typed in %pylab inline, did it gives you back any error? Or some kind of message? And how did you started the qtconsole? Also did you updated yourself to the new version of pandas and ipython, since anaconda comes with the 0.11 version of pandas, and 0.13.2 version of IPython Aug 22, 2013 at 19:13
  • those versions are correct. they need to be higher versions? Aug 22, 2013 at 19:26
  • i tried installing a better version of pandas through call("pip install --upgrade pandas", shell=True) but it returned 0 Aug 22, 2013 at 19:28
  • 1
    No, don't use pip with anaconda :D Use conda: conda update pandas and conda update ipython. But you haven't answered me the more important question about the error message and how did you started the qtconsole. Aug 22, 2013 at 19:34
  • FYI returning 0 indicates success. Aug 22, 2013 at 21:22

2 Answers 2

31

Plots are not displayed until you run

plt.show()

9

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.