Screenshot instructions:
Windows
Mac
Red Hat Linux
Ubuntu
Click URL instructions:
Rightclick on ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)
From: Laurent Dufrechou <laurent.dufrechou@gm...>  20080728 23:04:02
Attachments:
Message as HTML

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: You've 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 don't understand how you set the over/under value.) Laurent 
From: Andrew Straw <strawman@as...>  20080729 00:16:22

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: > > > > You’ve 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 don’t understand how you set the over/under value…) Dear Laurent, if I understand you correctly, set vmin=10 and vmax=250 and it will do what you want. Andrew 
From: Eric Firing <efiring@ha...>  20080729 00:39:01

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: > > > > You’ve 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 don’t understand how you set the over/under value…) If you don't really care how many colors are in the map, then for your 0255 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 
From: Laurent Dufréchou <laurent.dufrechou@gm...>  20080729 09:15:51

Hi andrew, eric, Excellent that is exactly what I was looking for :) Laurent > Message d'origine > De : Eric Firing [mailto:efiring@...] > Envoyé : mardi 29 juillet 2008 02:39 > À : Laurent Dufrechou > Cc : matplotlibusers@... > Objet : Re: [Matplotlibusers] 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 > 0255 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 