Re: [Matplotlib-users] colormap shift
Hi, I once was indicated a way to extract colors from exsiting colormaps: I just answered a question on Stackoverflow and maybe you can have a look. all code in pylab mode a = np.arange(100).reshape(10,10) #here is the image with white and black end imshow(a,cmap=mat.cm.binary) colorbar() #we extract only the 0.2-->0.7 part of original colormap and make a new one #so that the white and black end are removed rgba_array = mat.cm.binary(np.linspace(0,1,num=10,endpoint=True)) extract_rgba_array_255 = rgba_array[2:8,0:3] imshow(a,cmap=mat.colors.ListedColormap(extract_rgba_array_255)) colorbar() cheers, Chao -- View this message in context: http://matplotlib.1069221.n5.nabble.com/colormap-shift-tp39660p39707.html Sent from the matplotlib - users mailing list archive at Nabble.com. -- Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_nov ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] colormap shift
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 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.00, 0.00, 0.00), > (0.01, 1.00, 1.00), > (0.50, 0.50, 0.50), > (1.00, 0.00, 0.00) > ), > 'green' : ( > (0.00, 0.00, 0.00), > (0.01, 1.00, 1.00), > (0.50, 0.50, 0.50), > (1.00, 0.00, 0.00) > ), > 'blue' : ( > (0.00, 0.00, 0.00), > (0.01, 1.00, 1.00), > (0.50, 0.50, 0.50), > (1.00, 0.00, 0.00) > ) > } > > 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
Re: [Matplotlib-users] colormap shift
On 11/5/12 3:50 PM, klo uo wrote: > 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 Nice! I couldn't resist doing a Sage interact version of the slider thing: http://aleph.sagemath.org/?q=89b0c945-2ce3-4645-bf61-dbe0eed2c5cd&lang=sage Thanks, Jason -- Jason Grout -- 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
Re: [Matplotlib-users] colormap shift
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.00, 0.00, 0.00), (0.01, 1.00, 1.00), (0.50, 0.50, 0.50), (1.00, 0.00, 0.00) ), 'green' : ( (0.00, 0.00, 0.00), (0.01, 1.00, 1.00), (0.50, 0.50, 0.50), (1.00, 0.00, 0.00) ), 'blue' : ( (0.00, 0.00, 0.00), (0.01, 1.00, 1.00), (0.50, 0.50, 0.50), (1.00, 0.00, 0.00) ) } 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
[Matplotlib-users] colormap shift
Hi all, I am a newbie in matplotlib and I'd like to use colormap for z-axis. I can use in basic mode but would like to shift the existed colormap - binary - for using in this way: i would not like to set the white color for z=0.0 For describing: I would like to use the binary colormap but without the white color because this color I would like to leave for not-defined value for (x,y). Is it possible to do this? Maybe create new colormap on the basis of the "binary" but without the white color. Any suggestions? Thanks in advance for your help. best, Marian -- 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