|
From: Jeff W. <js...@fa...> - 2005-08-25 23:13:31
|
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 : Jef...@no... 325 Broadway Office : Skaggs Research Cntr 1D-124 Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg |
|
From: Helge A. <he...@gm...> - 2005-08-26 08:25:38
|
On 8/26/05, Jeff Whitaker <js...@fa...> 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
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=3D0.0)
etc. for pylab
Helge
|
|
From: Vidar G. <vid...@37...> - 2005-08-26 22:48:02
|
===== Original message from Jeff Whitaker | Thu, 25 Aug 2005: > I've created matplotlib colormaps from all the color tables at > http://colorbrewer.org, and > http://geography.uoregon.edu/datagraphics/color_scales.htm thanks for providing this, i hope this will be included in the matplotlib distribution, along with your script for previewing and listing all colormaps? (see modification of original code below.) i would like to mention another archive of color gradients, http://cpt-city.org.uk/. two examples of color gradients found here that i think might be useful for plotting data: Nonlinear grays, e.g. gamma={1/3, 0.5, 0.8, 1.25, ..} (human vision are more sensitive in the lighter range) http://cpt-city.org.uk/tl/ Subtle close-to-grayscale gradients, like for instance the sephia and cyanotype tinted monochrome colormaps found here: http://cpt-city.org.uk/erj/multiple/ """ Usage: colormap-preview.py [cmapname] Adapted from original code by Jeff Whitaker http://sourceforge.net/mailarchive/message.php?msg_id=12764609 """ import matplotlib.cm as cm import pylab as p 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__": names = cm.datad.keys() import sys if len(sys.argv) > 1: cmapname = sys.argv[1] else: print len(names), 'total color maps' print sorted(names) cmapname = raw_input('color map name: ') if cmapname not in names: raise KeyError, 'invalid colormap name,' +\ ' valid names are '+repr(names) plot_colorbar(cmapname) ## end of Python code -- Vidar Bronken Gundersen blogged: http://www.37mm.no/blog/ColorBrewer_schemes_for_Matplotlib.html |
|
From: John H. <jdh...@ac...> - 2005-08-29 22:37:02
|
>>>>> "Vidar" == Vidar Gundersen <vid...@37...> writes:
Vidar> thanks for providing this, i hope this will be included in
Vidar> the matplotlib distribution, along with your script for
Vidar> previewing and listing all colormaps? (see modification of
Vidar> original code below.)
I haven't been able to find any licensing information for the color
scales at colorbrewer or http://geography.uoregon.edu/datagraphics .
Does anyone know what their license is, if any?
JDH
|
|
From: Jeff W. <js...@fa...> - 2005-08-30 01:25:04
|
John Hunter wrote: >>>>>>"Vidar" == Vidar Gundersen <vid...@37...> writes: >>>>>> >>>>>> > > Vidar> thanks for providing this, i hope this will be included in > Vidar> the matplotlib distribution, along with your script for > Vidar> previewing and listing all colormaps? (see modification of > Vidar> original code below.) > >I haven't been able to find any licensing information for the color >scales at colorbrewer or http://geography.uoregon.edu/datagraphics . >Does anyone know what their license is, if any? > >JDH > > > John: Colorbrewer uses an apache-style license (http://www.personal.psu.edu/faculty/c/a/cab38/ColorBrewer/ColorBrewer_updates.html). I don't know about the DataGraphics color schemes. -Jeff -- Jeffrey S. Whitaker Phone : (303)497-6313 NOAA/OAR/CDC R/CDC1 FAX : (303)497-6449 325 Broadway Web : http://www.cdc.noaa.gov/~jsw Boulder, CO, USA 80305-3328 Office: Skaggs Research Cntr 1D-124 |