Michael Hearne wrote:
> Does anyone here have any experience converting GMT color palettes 
> into pylab colormaps?  I took a stab at it, and the results are not 
> really what I expected.
>
> GMT, for the unfamiliar, is a scientific plotting/mapping package that 
> I'm doing my best to rid myself of.  If you've never heard of it, then 
> you can probably ignore this message.
>
> Here's my attempt at bringing in a GMT color palette:
>
> #!/usr/bin/python
>
> from pylab import *
>
> #GMT color palette - Colors are specified by a RGB triplet with each 
> value in the range
> #0-255.  The palette below specifies that a data value between 1 and 2 
> will be assigned a color
> #linearly interpreted between the colors (255,255,255) and (191,204,255).
>
> # 0       255     255     255     1       255     255     255
> # 1       255     255     255     2       191     204     255
> # 2       191     204     255     3       160     230     255
> # 3       160     230     255     4       128     255     255
> # 4       128     255     255     5       122     255     147
> # 5       122     255     147     6       255     255     0
> # 6       255     255     0       7       255     200     0
> # 7       255     200     0       8       255     145     0
> # 8       255     145     0       9       255     0       0
> # 9       255     0       0       10      200     0       0
> # 10      200     0       0       13      128     0       0
>
> cdict = {'red': ((0.0,1.00,1.0),
>                  (0.1,1.00,0.75),
>                  (0.2,0.75,0.63),
>                  (0.3,0.63,0.50),
>                  (0.4,0.50,0.48),
>                  (0.5,0.48,1.00),
>                  (0.6,1.00,1.00),
>                  (0.7,1.00,1.00),
>                  (0.8,1.00,1.00),
>                  (0.9,1.00,0.78),
>                  (1.0,0.78,0.50)),
>          'green': ((0.0,1.00,1.00),
>                    (0.1,1.00,0.80),
>                    (0.2,0.80,0.90),
>                    (0.3,0.90,1.00),
>                    (0.4,1.00,1.00),
>                    (0.5,1.00,1.00),
>                    (0.6,1.00,0.78),
>                    (0.7,0.78,0.57),
>                    (0.8,0.57,0.00),
>                    (0.9,0.00,0.00),
>                    (1.0,0.00,0.00)),
>          'blue': ((0.0,1.00,1.00),
>                   (0.1,1.00,1.00),
>                   (0.2,1.00,1.00),
>                   (0.3,1.00,1.00),
>                   (0.4,1.00,0.58),
>                   (0.5,0.58,0.00),
>                   (0.6,0.00,0.00),
>                   (0.7,0.00,0.00),
>                   (0.8,0.00,0.00),
>                   (0.9,0.00,0.00),
>                   (1.0,0.00,0.00))}
>          
> my_cmap = matplotlib.colors.LinearSegmentedColormap('my_colormap',cdict)
> pcolor(rand(10,10),cmap=my_cmap)
> colorbar()
> savefig('colormap.png')
>
Michael:  The basemap toolkit includes the GMT colormaps.  To access 
them, import cm from the basemap namespace (from 
matplotlib.toolkits.basemap import cm).  The names are prefixed with 'GMT_'.

-Jeff

-- 
Jeffrey S. Whitaker         Phone  : (303)497-6313
Meteorologist               FAX    : (303)497-6449
NOAA/OAR/PSD  R/PSD1        Email  : [EMAIL PROTECTED]
325 Broadway                Office : Skaggs Research Cntr 1D-124
Boulder, CO, USA 80303-3328 Web    : http://tinyurl.com/5telg


-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to