matplotlib not plotting, giving output [<matplotlib.lines.Line2D object at 0x102e58810>]

0 views
Skip to first unread message

tim....@gmail.com

unread,
Mar 26, 2014, 11:06:26 AM3/26/14
to anac...@continuum.io
Hello,

I installed python recently and have been trying to learn how to use it for some scientific computing. I tried to do a simple plot following some online instruction, but matplotlib and pylab are giving me some strange results. In particular, here is what happened when I tried to make a plot from the python interpreter:

------------------------------

Python 2.7.6 |Anaconda 1.8.0 (x86_64)| (default, Jan 10 2014, 11:23:15) 

[GCC 4.0.1 (Apple Inc. build 5493)] on darwin

Type "help", "copyright", "credits" or "license" for more information.

>>> import matplotlib.pyplot

>>> matplotlib.pyplot.plot([1,2,3])

[<matplotlib.lines.Line2D object at 0x102e58810>]

>>>

------------------------------

I also tried Ipython. Specifically, I ran

$ ipython notebook --pylab=inline

then from the notebook I ran

[1] import pylab

[2] pylab.plot([1,2,3])

and got the the output below, plus a plot of a line ... so that's a bit better, I think.

[<matplotlib.lines.Line2D at 0x104b263d0>]

 Is there something I need to do differently to make plots from the interpreter? Maybe I installed something incorrectly? Any advice is most welcome!

Thanks,
Tim


Joe Kington

unread,
Mar 26, 2014, 3:21:28 PM3/26/14
to anac...@continuum.io
An interactive window won't be displayed until you explicitly show it, unless you specify otherwise.

To display an interactive window with the plot, call `plt.show()`.  This stops execution and enters the gui backend's (e.g. Tk, Qt, etc) main loop.

Alternately, if you'd prefer, you can use `plt.ion()` to make the plot display immediately when working interactively. (This is also a matplotlibrc setting.)  However, because `ion()` makes things non-blocking, if you use it inside of a script without calling `show()` the program will end before you have a chance to interact with the plot..

Hope that clears things up a bit.
-Joe



--
Anaconda Community Support Group Brought to you by Continuum Analytics
---
You received this message because you are subscribed to the Google Groups "Anaconda - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to anaconda+u...@continuum.io.
To post to this group, send email to anac...@continuum.io.
Visit this group at http://groups.google.com/a/continuum.io/group/anaconda/.

Reply all
Reply to author
Forward
0 new messages