Thanks for your reply. It's really nice. But, can you provide the code (part of it) where the colormap start from "very light gray" to "black" in the range (0,1). And all of the points >1 are black one and =0.0 IS NOT white. I have 2D map with defined pair (x,y) and the values for them, but also there are the pairs where I defined the value out of range (z=5.). So I would like to show the 2D map in grayscale ((x,y),z) but use WHITE color for z=5. Because when I set "cm.set_over('white')" and the white is also for z=0.0 (not shifted colormap), you can't distinguish these values - if it is z=5 or z=0. Of course, the possible way is to use rgb colormaps (not grayscale) but I can't do it because I need BW version of the figure.
Thanks in advance for your help. Dňa Mon, 5 Nov 2012 22:50:31 +0100 klo uo <klo...@gmail.com> napísal: > I asked same question with different problem here: > http://matplotlib.1069221.n5.nabble.com/How-to-shift-colormap-td18451.html > > You can see there how to use Gimp and create mpl colormap and then later > there is nifty code that will allow you to shift colormaps with a slider > > >From your problem I assume you would want the first. > > Here is ready made for you: > > ======================================== > import matplotlib as mpl > import matplotlib.pyplot as plt > > ccm = { > 'red' : ( > (0.000000, 0.000000, 0.000000), > (0.000001, 1.000000, 1.000000), > (0.500000, 0.500000, 0.500000), > (1.000000, 0.000000, 0.000000) > ), > 'green' : ( > (0.000000, 0.000000, 0.000000), > (0.000001, 1.000000, 1.000000), > (0.500000, 0.500000, 0.500000), > (1.000000, 0.000000, 0.000000) > ), > 'blue' : ( > (0.000000, 0.000000, 0.000000), > (0.000001, 1.000000, 1.000000), > (0.500000, 0.500000, 0.500000), > (1.000000, 0.000000, 0.000000) > ) > } > > cm = mpl.colors.LinearSegmentedColormap('my_map', ccm) > > from numpy import outer, arange, ones > a = outer(arange(0, 1, 0.01), ones(10)) > > plt.imshow(a, cmap=cm) > plt.show() > ======================================== ------------------------------------------------------------------------------ LogMeIn Central: Instant, anywhere, Remote PC access and management. Stay in control, update software, and manage PCs from one command center Diagnose problems and improve visibility into emerging IT issues Automate, monitor and manage. Do more in less time with Central http://p.sf.net/sfu/logmein12331_d2d _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users