Using color in fill


I found the following post on matplotlib-users. However, post reading
the 'docstring', I'm still unable to figure it out. I don't know how
to call the __call__ function in LinearSegmentedColormap in
Could someone please help me out? All I need is a one-line command
that tells me how to give this beast a number between 0 and 1 and get
an rgb tuple.



From: Perry Greenfield <perry@...684...>
Re: Using color in fill
2005-01-06 12:01

Yes, colormaps are callable so you can call the colormap with either a
scalar value or an
array of values and what will be returned is a tuple of rgba values or
an array (shape
= 4, nelements). See the docstring on __call__ for
LinearSegmentedColormap in


On Jan 6, 2005, at 3:18 PM, Carol Leger wrote:

> I am using fill to make filled polygons. I want to fill the polygons
> with colors that reflect data values, similar to what imshow does.
> Is there a way to extract the rgb tuples from a Colormap? This could
> be an array of N tuples, each tuple containing 3 0-1 floats that
> describe the color or three separate arrays, one each for red, green
> and blue.
> I made the mistake of using some non-public attributes of the class
> colorMap to accomplish this in a previous version of matplotlib. That
> was a mistake since Colormap._red_lut, Colormap._green_lut and
> Colormap._blue_lut no longer exist.
> Once I have the array of tuples, I can determine which one I want and
> create a hex string using rgb2hex to get a color suitable for use with
> fill.
> I need the flexability to make the same plot using several different
> color maps.
> --
> Ms. Carol A. Leger
> SRI International Phone: (650) 859-4114
> 333 Ravenswood Avenue G-273
> Menlo Park, CA 94025 e-mail: leger@...685...
> -------------------------------------------------------
> The SF.Net email is sponsored by: Beat the post-holiday blues
> Get a FREE limited edition t-shirt from ThinkGeek.
> It"s fun and FREE -- well, almost....
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@...686...