On 07/29/2011 06:03 PM, Alan G Isaac wrote:
> I have many lines to plot.
> Each line has an associated parameter value.
> I'd like to pick the color for each line
> based on its parameter value by mapping
> possible parameter values to the colors
> in a color map (e.g., gist_rainbow),
> retrieving colors one at a time (based
> on the parameter value for a line).
>
> If two lines have the same parameter value,
> I need them to have exactly the same color.
>
> Hints?

Tony's reply may be the right approach for you; but an alternative, if 
you are plotting a set of lines all at once, is to use a LineCollection, 
which takes a colors kwarg.  (Like all Collections, a LineCollection 
includes the cm.ScalarMappable mixin.)  See 
http://matplotlib.sourceforge.net/examples/pylab_examples/line_collection2.html
but note that the lines within the collection don't have to have the 
same number of points.

Also, Tony's method could be modified easily to use a norm (e.g., an 
instance of colors.Normalize or of a subclass) in addition to a cmap.

Eric

>
> Thanks,
> Alan Isaac
>
> ------------------------------------------------------------------------------
> Got Input?   Slashdot Needs You.
> Take our quick survey online.  Come on, we don't ask for help often.
> Plus, you'll get a chance to win $100 to spend on ThinkGeek.
> http://p.sf.net/sfu/slashdot-survey
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users


------------------------------------------------------------------------------
Got Input?   Slashdot Needs You.
Take our quick survey online.  Come on, we don't ask for help often.
Plus, you'll get a chance to win $100 to spend on ThinkGeek.
http://p.sf.net/sfu/slashdot-survey
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to