a bunch of extra colormaps

I've created matplotlib colormaps from all the color tables at http://colorbrewer.org, and http://geography.uoregon.edu/datagraphics/color_scales.htm. You can grab them at http://www.cdc.noaa.gov/people/jeffrey.s.whitaker/python/extracmaps.py.gz. Also included are the Generic Mapping Tools colormaps (at least the ones that are different from the built in mpl colormaps), for a total of 60. You can just paste the contents of that file into cm.py just above the "def get_cmap" line (although this will not make them available via pylab calls like 'jet()' and 'hot()'). To get a quick view of what the colormaps look like, I use this little script:

import matplotlib.cm as cm
import pylab as p
names = cm.datad.keys()
print len(names),'total color maps'
def plot_colorbar(cmapname,nsteps=None):
    colormap = cm.__dict__[cmapname]
    fig=p.figure(figsize=(8,1))
    ax = fig.add_axes([0.05,0.05,0.9,0.70])
    if nsteps == None:
        nsteps = colormap.N+1
    clevs = p.linspace(0,1,nsteps+1)
    C = p.array([clevs,clevs])
    X,Y = p.meshgrid(clevs,[0,1])
    levs,coll = ax.contourf(C, Y, X, nsteps-1, cmap=colormap)
    ax.set_xticks([])
    ax.set_yticks([])
    p.title(cmapname)
    p.show()
if __name__ == "__main__":
    cmapname = raw_input('color map name:')
    if cmapname not in names:
        raise KeyError, 'invalid colormap name, valid names are '+repr(names)
    plot_colorbar(cmapname)

Enjoy!

-Jeff

···

--
Jeffrey S. Whitaker Phone : (303)497-6313
Meteorologist FAX : (303)497-6449
NOAA/OAR/CDC R/CDC1 Email : Jeffrey.S.Whitaker@...259...
325 Broadway Office : Skaggs Research Cntr 1D-124
Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg

this is great, and I think the matlab way with a function for each
color map pollutes the namespace too much. I humbly suggest a syntax
like
  colormap('hot')
or to give bluetones for values < 0, greenish and brown above:
  colormap('earth', zerolevel=0.0)
etc. for pylab

Helge

···

On 8/26/05, Jeff Whitaker <jswhit@...146...> wrote:

"def get_cmap" line (although this will not make them available via
pylab calls like 'jet()' and 'hot()'). To get a quick view of what the