|
From: klo uo <kl...@gm...> - 2012-11-05 21:50:39
|
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() ======================================== |