On Sun, Aug 23, 2009 at 1:24 PM, Eric Firing<efir...@hawaii.edu> wrote:
> Dr. Phillip M. Feldman wrote:
>> I've been trying to understand how colormaps work.  I've been through the
>> Matplotlib User's Guide (Release 0.98.6svn, dated June 14, 2009), but the
>> section on colormaps has not yet been written.  If anyone can point me to
>
> This is my fault; I need to write that.
>
>> documentation or provide an explanation, I'd be grateful.
>
> This may help:
> http://matplotlib.sourceforge.net/api/colors_api.html
> http://matplotlib.sourceforge.net/api/cm_api.html
>
> and this:
>
> http://matplotlib.sourceforge.net/examples/pylab_examples/custom_cmap.html
>
> Beware: the posted docs are current, so may include functions that are
> not in the version of mpl you have installed.
>
> If you search for "cmap" using the search box in the doc webpage
> sidebar, you will get many more examples of the use of colormaps.
> Browsing these examples may be the quickest way of getting the basic
> ideas of how cmaps (and their partners, norms) are used.
>
> Looking at the source code is also helpful.

This example may be instructive: it takes a list of colors and creates
a colormap that interpolates smoothly between them from normalized
0..1.

But yes, a tutorial on the sphinx site would be great (at the sprint
yesterday one of the students wrote a nice image tut but I haven't
gotten it from him yet for upload)


    @staticmethod
    def from_list(name, colors, N=256):
        """
        Make a linear segmented colormap with *name* from a sequence
        of *colors* which evenly transitions from colors[0] at val=1
        to colors[-1] at val=1.  N is the number of rgb quantization
        levels.
        """

        ncolors = len(colors)
        vals = np.linspace(0., 1., ncolors)

        cdict = dict(red=[], green=[], blue=[])
        for val, color in zip(vals, colors):
            r,g,b = colorConverter.to_rgb(color)
            cdict['red'].append((val, r, r))
            cdict['green'].append((val, g, g))
            cdict['blue'].append((val, b, b))

        return LinearSegmentedColormap(name, cdict, N)

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to