On Jun 4, 2009, at 19:48 , Esmail wrote:
Someone recently generously shared this code with me on the python
since I was the one to share this with you, I might be able to answer
a couple questions. :)
list. While I have used pylab/matplotlib a bit, I didn't know about
ion() (line 12),
ion() sets interactive mode on, so that the plot will update and show
before the script is done. I usually use the pylab mode of ipython,
so I don't have to use this, but I put it in to work with the regular
python interpreter.
nor am I sure about what is happening on line 19 and
21, does plot return a list?
18 if t == 0: # first time calling
19 h = plot(x,y,'ro')
20 else:
21 h[0].set_data(x,y)
it returns a list of line-type objects. since you are plotting a lot
of dots, but one (invisible) line, then there is only one element in
this list. If you had passed a 2D array into plot, then it would
plot several lines, with possibly different properties. You can set
the properties directly by calling the various set_ methods on the
line-type object. In this case, the first call (when t==0) I make a
regular plot, and get the object. After that, I set the data on the
object directly, and then draw (so that it draws immediately). This
is much faster than doing another plot command.
There may be better ways to do this animation, but I do it this way
most of the time.
Why is it subscripted to? Hadn't seen
draw() before either, though I know show() .. these sort of things I
am curious to learn about before I see them in code for the first
time.
actually, that's how I learned most of it...by seeing it in code at
some point. :)
hope this helps,
bb
--
Brian Blais
bbl...@bryant.edu
http://web.bryant.edu/~bblais
------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises
looking to deploy the next generation of Solaris that includes the latest
innovations from Sun and the OpenSource community. Download a copy and
enjoy capabilities such as Networking, Storage and Virtualization.
Go to: http://p.sf.net/sfu/opensolaris-get
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users