Hi andrew, eric, Excellent that is exactly what I was looking for :)
Laurent > -----Message d'origine----- > De : Eric Firing [mailto:[EMAIL PROTECTED] > Envoyé : mardi 29 juillet 2008 02:39 > À : Laurent Dufrechou > Cc : matplotlib-users@lists.sourceforge.net > Objet : Re: [Matplotlib-users] Colormap cluttering? > > Laurent Dufrechou wrote: > > Hello, > > > > > > > > I would like to have a cluttering functionality to colorbar. > > > > http://en.wikipedia.org/wiki/Clutter_(radar) > > > > > > > > Before writing it, I would like to know if there is a way to doing it > > with matplotlib. > > > > What I mean by cluttering is: > > > > > > > > Youve got a colormap associated with a graphic where value goes from > 0 > > to 255 for example. > > > > Assigning a classical colormap (for example cm.jet) 0 value will be > blue > > and 255 one will be red. > > > > What I need is a low clutter and max clutter, if I set low clutter > to > > 10 and ax cluter to 250 then: > > > > Blue will be for value from 0 to 10 > > > > Then the colormap do his job from 10 to 250 and finally > > > > From 250 to 255 colr will be set to max one = red. > > > > > > > > Is it ever done in matplotlib, if not what could be the strategy > here ? > > > > I was thinking of set_over/set_under but seems not be exactly what I > > need because I want to recreate the colormap from 10 to 250 with N > segments. > > > > (moreover I dont understand how you set the over/under value ) > > If you don't really care how many colors are in the map, then for your > 0-255 example, try this: > > import numpy as np > import matplotlib.pyplot as plt > fakedata = np.random.rand(10,20) * 255.0 > cmap = plt.cm.jet > norm = plt.Normalize(vmin=100, vmax=150) > plt.imshow(fakedata, cmap=cmap, norm=norm, interpolation="nearest") > plt.colorbar(extend="both") > plt.show() > > I made the colored range small to emphasize what you call the > "cluttering" effect. > > We are taking advantage of the default, which is that the over and > under > values are the top and bottom ends of the colormap. If you want other > colors for the ends, then after defining your cmap, use, e.g.: > > cmap.set_under('w') > cmap.set_over('k') > > If you want to use a smaller number of colors in your colormap, then > you > need to make the colormap this way, for example: > > from matplotlib.colors import LinearSegmentedColormap > from matplotlib._cm import _jet_data > cmap = LinearSegmentedColormap("yourname", _jet_data, N=10) > > (I should add a helper function to make this more obvious and > straightforward.) > > Eric ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users