I’m trying to understand the usage of Colormaps, and LinearSegmentedColormaps in particular.
I can create segmentdata that looks like the example at the bottom of this message. Each color has a 3x9 list of values.
I can then construct a LinearSegmentedColormap as follows:
palette = LinearSegmentedColormap(‘my_colormap’,cdict)
the ‘N’ attribute of my palette object reports that the length of the colormap is 256. However, when I try to retrieve the color tuple for any value above 50, I get black:
palette(51) => (0.0, 0.0, 0.0, 1.0)
Why aren’t there 256 different colors in my colormap?
–Mike
cdict = {‘blue’: [[0.0, 1.0, 1.0],
[9.99999974738e-05, 0.749019622803, 0.749019622803],
[0.0010000000475, 0.623529434204, 0.623529434204],
[0.00200000009499, 0.498039215803, 0.498039215803],
[0.00999999977648, 0.372549027205, 0.372549027205],
[0.019999999553, 0.247058823705, 0.247058823705],
[0.10000000149, 0.121568627656, 0.121568627656],
[0.20000000298, 0.0, 0.0],
[1.0, 0.0, 0.0]],
‘green’: [[0.0, 1.0, 1.0],
[9.99999974738e-05, 0.749019622803, 0.749019622803],
[0.0010000000475, 0.623529434204, 0.623529434204],
[0.00200000009499, 0.498039215803, 0.498039215803],
[0.00999999977648, 0.372549027205, 0.372549027205],
[0.019999999553, 0.247058823705, 0.247058823705],
[0.10000000149, 0.121568627656, 0.121568627656],
[0.20000000298, 0.0, 0.0],
[1.0, 0.0, 0.0]],
‘red’: [[0.0, 1.0, 1.0],
[9.99999974738e-05, 0.749019622803, 0.749019622803],
[0.0010000000475, 0.623529434204, 0.623529434204],
[0.00200000009499, 0.498039215803, 0.498039215803],
[0.00999999977648, 0.372549027205, 0.372549027205],
[0.019999999553, 0.247058823705, 0.247058823705],
[0.10000000149, 0.121568627656, 0.121568627656],
[0.20000000298, 0.0, 0.0],
[1.0, 0.0, 0.0]]}
···
Michael Hearne
mhearne@…924…
(303) 273-8620
USGS National Earthquake Information Center
1711 Illinois St. Golden CO 80401
Senior Software Engineer
Synergetics, Inc.