Strange set of errors

Kurt Smith kwmsmith at gmail.com
Fri Aug 3 21:58:31 CEST 2007


Sorry, forgot to "Reply to all."

On 8/3/07, Stephen Webb <sdavis.webb at gmail.com> wrote:
> Greetings all,

<<snippage>>

> Also, I've been having trouble with the plot function in matplotlib. For
> example, I enter the following in the terminal:
>
>  >>> from pylab import *
> >>> plot([1,2,3])
> [<matplotlib.lines.Line2D instance at 0x16adda30>]
>

I can help you with your second problem: matplotlib is doing what it
should, all you need to do is tell it to show() the figure you created
(with the plot on it.)  Note -- if you call the show() function, you
will turn control over to the backend (in my case, TkAgg), and lose
the ability to issue interactive commands afterwards.  A solution is
to use the ion() (stands for "interactive-on") function call before
issuing plotting commands:

>>> from pylab import *
>>> ion()
>>> plot([1,2,3])
[<matplotlib.lines.Line2D instance at 0x2cb60a8>]
>>> # image is shown here

See http://matplotlib.sourceforge.net/interactive.html for an
exhaustive explanation.

> Every time I run the plot([1,2,3]) I get a different ending number that
> seems to vary randomly.

The "[<matplotlib.lines.Line2D instance at 0x2cb60a8>]" is what the
plot() function returns -- a list of instances of the Line2D class,
and it tells you their locations in memory (hence the hex number
starting with 0x).  The hex number can be used to uniquely identify
this object, as in the id(object) call.

Hope this helps,

Kurt



More information about the Python-list mailing list