Dr. Phillip M. Feldman wrote: > I'd like to be able to create and use a custom colormap. I'm creating the > colormap via > the following statement: > > matplotlib.colors.ListedColormap([(0,0,0),(0.6,0,0),(0,0.6,0),(0.6,0.6,0)], > name='Earth')
Assign it to a variable, like earth_cmap = matplotlib.colors.ListedColormap( [(0,0,0),(0.6,0,0),(0,0.6,0),(0.6,0.6,0)], name='Earth') and then use cmap=earth_cmap as your kwarg specification. The ability to register user-generated cmaps so that they can be retrieved via get_cmap is very new, and not present in 0.98.5. It is in the latest release (0.99.1), though. You would need to use the register_cmap function. Eric > > The above statement appears to work, but when I attempt to use this > colormap, I > get the error shown below. Any suggestions will be appreciated. > > AssertionError Traceback (most recent call last) > > art.py in <module>() > 253 > 254 # Plot z as image using specified color map: > --> 255 pyplot.imshow(z, origin='lower', cmap=get_cmap(map_names[n_map-1]), > 256 extent=[x.min(),x.max(),y.min(),y.max()]) > 257 > > C:\Program > Files\Python25\lib\site-packages\matplotlib-0.98.5.2n2-py2.5-win32.egg\matplotlib\cm.pyc > in get_cmap(name, lut) > 19 if lut is None: lut = mpl.rcParams['image.lut'] > 20 > ---> 21 assert(name in datad.keys()) > 22 return colors.LinearSegmentedColormap(name, datad[name], lut) > 23 > > AssertionError: ------------------------------------------------------------------------------ Come build with us! The BlackBerry® Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users