ts.plot() pandas: No plot!

Jason Swails jason.swails at gmail.com
Mon Feb 1 09:18:41 EST 2016


On Sun, Jan 31, 2016 at 9:08 PM, Paulo da Silva <
p_s_d_a_s_i_l_v_a_ns at netcabo.pt> wrote:

> Às 01:43 de 01-02-2016, Mark Lawrence escreveu:
> > On 01/02/2016 00:46, Paulo da Silva wrote:
> ...
>
> >>
> >
> > Is it as simple as adding a call to ts.show() ?
> >
> Thanks for the clue!
> Not so simple however.
> Needed to do
> import matplotlib.pyplot as plt
> plt.show()
>

​What you saw ts.plot() return was the matplotlib artists (the things that
will be drawn on whatever "canvas" is provided -- either saved to an image
or drawn to a GUI widget).  So whenever you see this kind of return value,
you know you need to call the matplotlib.pyplot.show function in order to
generate a canvas widget (with whatever backend you choose) and draw it.

If you want to do this kind of interactive plotting (reminiscent, I've
heard, of Matlab), I would highly recommend checking out IPython.  You can
use IPython's notebook or qtconsole and embed plots from matplotlib
directly in the viewer.  For example, try this:

ipython qtconsole

This opens up a window, then use the magic command "%matplotlib inline" to
have all plots sent directly to the ipython console you are typing commands
in.  I've found that kind of workflow quite convenient for directly
interacting with data.

HTH,
Jason



More information about the Python-list mailing list