On Thu, May 27, 2010 at 5:44 PM, Eric Firing <efir...@hawaii.edu> wrote: > You can't do this via any manipulation of the colormap, or any fancier > colormap specification--instead, you have to manipulate the data value. For > example, you could identify the "over" values in your data, and then use 2-D > interpolation to replace them with the values you want. > > Basemap includes a 2-D interpolation routine: > > from mpl_toolkits.basemap import interp >
Thanks! >> >> This is partially achieved with "white" (and I suppose I could pick >> "grey" or "black"), but I think it might be nicer if it were a pure >> mixture, rather than a mixture of the surrounding colors and the >> "over" color. >> >> The script is attached below. Sorry it is a bit long, but I needed a >> discrete colormap. Can we get cmap_discrete() into matplotlib? > > No, because it doesn't make much sense, given the mpl paradigm in which a > colormap and a norm work together. If you want 4 colors, make a colormap > with 4 colors, and use a norm that maps your data to those 4 colors. > > For example: > > cm4 = get_cmap('jet', 4) > cm4a = mpl.colors.ListedColormap(get_cmap('jet', 256)([20, 70, 150, 200])) > > You can select any discrete set of colors you want using ListedColormap. > > Then you can use the default Normalize, or a custom BoundaryNorm, to map > data ranges to the colors. You just don't need a lookup table with 1024 > entries to specify 4 colors--it doesn't gain you anything. > Wonderful. Definitely makes the cookbook entry seem unnecessary ------------------------------------------------------------------------------ _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users