Trying again, a little more detail:

I am trying to use the color setting feature of SCATTER:

colors=cm.spectral(linespace(0,100,len(x))

then, plotting:

scatter(x,y,c=colors)

I get the error:

TypeError: c must be a matplotlib color arg or a sequence of them

But I don't understand.

x.shape

(600,)

colors.shape

(600,4)

so it appears to me that colors is indeed a sequence of intensities

the same length as x? What is wrong then??

Thanks,

.john

John Washakie wrote:

Trying again, a little more detail:

I am trying to use the color setting feature of SCATTER:

colors=cm.spectral(linespace(0,100,len(x))

then, plotting:

scatter(x,y,c=colors)

I get the error:

TypeError: c must be a matplotlib color arg or a sequence of them

But I don't understand.

x.shape

(600,)

colors.shape

(600,4)

so it appears to me that colors is indeed a sequence of intensities

the same length as x? What is wrong then??

No, colors is a sequence of colors in this example, and I think that even if it did not give an error, it would not do what you want; but yes, I don't think this should give an error. And, on my system, a rough equivalent does not. What mpl version are you using?

Regardless, I think what you want is more like this:

scatter(x, y, c=arange(len(x)), cmap=cm.spectral)

Then the colors will be determined from a table lookup in the spectral colormap based on the floating point values in c, with the smallest value mapped to the first color and the largest value mapped to tha last.

Eric

Eric,

Exactly. Thanks for your post. I finally figured it out, and wanted to

post here for completeness in case no one followed up, but I'm glad

that you did. So yes, the following:

scatter(x, y, c=arange(len(x)), cmap=cm.spectral)

is exactly what I wanted... except that for my data I had:

Yvar1, Yvar2, Yvar3, ...

All data was plotted against Yvar1, and the first plot was Yvar1 vs.

Time. I wanted the colors for all the plots to be reflective of Time,

and consistently across the subplots, thus I had to define Time and

then use:

scatter(x, y, c=Time, cmap=cm.spectral)

However, I didn't try the arange function, I probably could've done

something like:

t=arange(Time)

scatter(x, y, c=t, cmap=cm.spectral)

Anyway, thanks again!

.john