What then happens is the path is drawn "live", as in my python code below.
This is especially useful when teaching parametric equations in calculus. A typical question in that section might be: "find a parametrization for the unit circle that starts at (0,1) and moves around the circle one time in the counterclockwise direction." In this situation, the following is not helpful:
Because the student just sees sees the "finished" path. The comet command, on the other hand, allows the student to "see" that path as it is traced out in real time.
David.
···
On Feb 6, 2010, at 9:09 AM, Eric Firing wrote:
David Arnold wrote:
All,
I am still wondering why there is no comet command in matplotlib. I was successful with the following:
import matplotlib.pyplot as plt
import numpy as np
len=200
t=np.linspace(0,2*np.pi,len)
x=np.cos(t)
y=np.sin(t)
xd=[x[0]]
yd=[y[0]]
l,=plt.plot(xd,yd)
plt.axis([-1,1,-1,1])
for i in np.arange(1,len):
xd.append(x[i])
yd.append(y[i])
l.set_xdata(xd)
l.set_ydata(yd)
plt.draw()
plt.show()
But it seems that a comet function added to the matplotlib library would greatly simplify things for students using the interactive pylab in ipython.
I don't understand--what's the point of the example? What is "comet", and how does it simplify anything?
def comet(x, y, fmt='', step=1, **kwargs):
l, = plt.plot(x, y, fmt, **kwargs)
num_points = len(x)
for i in xrange(1, num_points + 1, step):
l.set_data(x[:i], y[:i])
plt.draw()
l.set_data(x, y)
plt.draw()
I think this could be better done using animation features of
matplotlib, but I never used them and I think they varies across
toolkits. Search the docs for animation examples anyway.
Goyo
···
El sáb, 06-02-2010 a las 10:21 -0800, David Arnold escribió:
What then happens is the path is drawn "live", as in my python code below.
This is especially useful when teaching parametric equations in calculus. A typical question in that section might be: "find a parametrization for the unit circle that starts at (0,1) and moves around the circle one time in the counterclockwise direction." In this situation, the following is not helpful:
Because the student just sees sees the "finished" path. The comet command, on the other hand, allows the student to "see" that path as it is traced out in real time.
David.
On Feb 6, 2010, at 9:09 AM, Eric Firing wrote:
> David Arnold wrote:
>> All,
>> I am still wondering why there is no comet command in matplotlib. I was successful with the following:
>> import matplotlib.pyplot as plt
>> import numpy as np
>> len=200
>> t=np.linspace(0,2*np.pi,len)
>> x=np.cos(t)
>> y=np.sin(t)
>> xd=[x[0]]
>> yd=[y[0]]
>> l,=plt.plot(xd,yd)
>> plt.axis([-1,1,-1,1])
>> for i in np.arange(1,len):
>> xd.append(x[i])
>> yd.append(y[i])
>> l.set_xdata(xd)
>> l.set_ydata(yd)
>> plt.draw()
>>
>> plt.show()
>> But it seems that a comet function added to the matplotlib library would greatly simplify things for students using the interactive pylab in ipython.
>
> I don't understand--what's the point of the example? What is "comet", and how does it simplify anything?
>
> Eric
>
------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net matplotlib-users List Signup and Options
def comet(x, y, fmt='', step=1, **kwargs):
l, = plt.plot(x, y, fmt, **kwargs)
num_points = len(x)
for i in xrange(1, num_points + 1, step):
l.set_data(x[:i], y[:i])
plt.draw()
l.set_data(x, y)
plt.draw()
I think this could be better done using animation features of
matplotlib, but I never used them and I think they varies across
toolkits. Search the docs for animation examples anyway.
Goyo
What then happens is the path is drawn "live", as in my python code below.
This is especially useful when teaching parametric equations in calculus. A typical question in that section might be: "find a parametrization for the unit circle that starts at (0,1) and moves around the circle one time in the counterclockwise direction." In this situation, the following is not helpful:
Because the student just sees sees the "finished" path. The comet command, on the other hand, allows the student to "see" that path as it is traced out in real time.
David.
On Feb 6, 2010, at 9:09 AM, Eric Firing wrote:
David Arnold wrote:
All,
I am still wondering why there is no comet command in matplotlib. I was successful with the following:
import matplotlib.pyplot as plt
import numpy as np
len=200
t=np.linspace(0,2*np.pi,len)
x=np.cos(t)
y=np.sin(t)
xd=[x[0]]
yd=[y[0]]
l,=plt.plot(xd,yd)
plt.axis([-1,1,-1,1])
for i in np.arange(1,len):
xd.append(x[i])
yd.append(y[i])
l.set_xdata(xd)
l.set_ydata(yd)
plt.draw()
plt.show()
But it seems that a comet function added to the matplotlib library would greatly simplify things for students using the interactive pylab in ipython.
I don't understand--what's the point of the example? What is "comet", and how does it simplify anything?
Eric
------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net matplotlib-users List Signup and Options
------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net matplotlib-users List Signup and Options