On Mon, May 9, 2011 at 5:11 PM, Pythonified <netdriveremail@gmail.com> wrote:


Pythonified wrote:
>
> I have been trying to assign different colors for each line I plot, where
> the colors are incrementally darkened (or lightened), or selected from a
> colorbar (e.g. rainbow).
>
> Any ideas?
>

I have found a simple and better way. One can chose from colors from a color
map:

>>import pylab as pl
>>import matplotlib.cm as cm
>>xval = pl.arange(0, 20, 0.2)
>>for i in range(256):
    ...  pl.plot(xval, pl.sin(xval)+i, c=cm.hot(i), lw=5)

This one if, for instance, picking from a color map called "hot". If one
wants to the colors to fade away, or darken, the "alpha" option can be
utilized or another color map in which colors darken or fade into another
color.

There is no need for a long sophisticated script.

Enjoy,
Pythonified

Nice trick. This can go into the gallery or somewhere else in scipy cookbook.


--
Gökhan