a lot of matplotlib examples i saw included the usage of line, i.e.
from pylab import *
import time
ion()
tstart = time.time() # for profiling
x = arange(0,2*pi,0.01) # x-array
line, = plot(x,sin(x))
for i in arange(1,200):
line.set_ydata(sin(x+i/10.0)) # update the data
draw() # redraw the canvas
print 'FPS:' , 200/(time.time()-tstart)
can anybody explain to me whats the difference between line and line, ?
returns the first one (which in your case is the only one)
It is the same as
line = plot(...)[0]
It is a special case of Python's sequence unpacking, e.g.:
a, b, c = [1, 2, 3]
Eric
···
On 06/15/2011 12:35 PM, jonasr wrote:
hello,
a lot of matplotlib examples i saw included the usage of line, i.e.
from pylab import *
import time
ion()
tstart = time.time() # for profiling
x = arange(0,2*pi,0.01) # x-array
line, = plot(x,sin(x))
for i in arange(1,200):
line.set_ydata(sin(x+i/10.0)) # update the data
draw() # redraw the canvas
print 'FPS:' , 200/(time.time()-tstart)
can anybody explain to me whats the difference between line and line, ?
Thank you for the fast reply, according to you line and "line," shouldt make
a difference in this case,
i tried the code with line and line, and it only works with line, ?
so you say if i use
a=[1,2,3]
then b, = a should be 1 ? i just get the error message to many values to
unpack ...
efiring wrote:
···
On 06/15/2011 12:35 PM, jonasr wrote:
hello,
a lot of matplotlib examples i saw included the usage of line, i.e.
from pylab import *
import time
ion()
tstart = time.time() # for profiling
x = arange(0,2*pi,0.01) # x-array
line, = plot(x,sin(x))
for i in arange(1,200):
line.set_ydata(sin(x+i/10.0)) # update the data
draw() # redraw the canvas
print 'FPS:' , 200/(time.time()-tstart)
can anybody explain to me whats the difference between line and line, ?
plot returns a list of lines, and
line, = plot(...)
returns the first one (which in your case is the only one)
It is the same as
line = plot(...)[0]
It is a special case of Python's sequence unpacking, e.g.:
a, b, c = [1, 2, 3]
Eric
------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking. http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net matplotlib-users List Signup and Options
Thank you for the fast reply, according to you line and "line," shouldt make
a difference in this case,
No, that's not what I said. Using "line" gives you a list with one element, but using "line," gives you the element itself, not the list.
i tried the code with line and line, and it only works with line, ?
so you say if i use
a=[1,2,3]
then b, = a should be 1 ? i just get the error message to many values to
unpack ...
Yes, when you use this automatic unpacking the number of items has to match. You can only use
a, b = rhs
when you *know* rhs will be a sequence with two, and only two, elements.
Eric
···
On 06/15/2011 12:53 PM, jonasr wrote:
efiring wrote:
On 06/15/2011 12:35 PM, jonasr wrote:
hello,
a lot of matplotlib examples i saw included the usage of line, i.e.
from pylab import *
import time
ion()
tstart = time.time() # for profiling
x = arange(0,2*pi,0.01) # x-array
line, = plot(x,sin(x))
for i in arange(1,200):
line.set_ydata(sin(x+i/10.0)) # update the data
draw() # redraw the canvas
print 'FPS:' , 200/(time.time()-tstart)
can anybody explain to me whats the difference between line and line, ?
plot returns a list of lines, and
line, = plot(...)
returns the first one (which in your case is the only one)
It is the same as
line = plot(...)[0]
It is a special case of Python's sequence unpacking, e.g.:
a, b, c = [1, 2, 3]
Eric
------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking. http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net matplotlib-users List Signup and Options