Hi Eric,

Matlab has two commands, comet and comet3, that animate the path. They are used as in the following Matlab code:

t=linspace(0,2*pi,2000);

x=-sin(t);

y=cos(t);

comet(x,y)

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:

t=linspace(0,2*pi,2000);

x=-sin(t);

y=cos(t);

plot(x,y)

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