On 07/31/2011 04:05 AM, Alan G Isaac wrote: > On 7/30/2011 12:03 AM, Alan G Isaac wrote: >> 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). > > > > As far as I can tell, the answer is the following. > 1. scale the parameter to fall in (0,1) > 2. get a color (rgba tuple) as cm.gist_rainbow(scaled_param) > 3. plot using that color
For completeness: You can call a Colormap instance with either a float in (0,1), or equivalently with an integer in (0, N-1), where N is the number of discrete colors in the lookup table, excluding the over, under, and "bad" colors. The standard colormaps in cm are all created with N=mpl.rcParams['image.lut'], defaulting to 256, but you can make a colormap with any value of N. Eric > > This works. > > Cheers, > 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