I am trying to vary the color of a line plotted from data in two arrays (eg. ax.plot(x,y)). The color should vary as the index into x and yincreases. I am essentially trying to capture the natural 'time' parameterization of the data in arrays x and y.

In a perfect world, I want something like:

fig = pyplot.figure()
ax  = fig.add_subplot(111)
x   = myXdata 
y   = myYdata

# length of x and y is 100
ax.plot(x,y,color=[i/100,0,0]) # where i is the index into x (and y)

to produce a line with color varying from black to dark red and on into bright red.

I have seen examples that work well for plotting a function explicitly parameterized by some 'time' array, but I can't get it to work with raw data...

Edit
Report