red-colors 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/colors.rb CHANGED
@@ -19,6 +19,7 @@ require_relative "colors/named_colors"
19
19
  require_relative "colors/colormap"
20
20
  require_relative "colors/listed_colormap"
21
21
  require_relative "colors/linear_segmented_colormap"
22
+ require_relative "colors/colormap_registry"
22
23
 
23
24
  module Colors
24
25
  # ITU-R BT.709 D65 white point
@@ -37,3 +38,5 @@ module Colors
37
38
  NamedColors[name]
38
39
  end
39
40
  end
41
+
42
+ require_relative "colors/colormap_data"
@@ -67,6 +67,18 @@ module Colors
67
67
  update_extreme_colors if @initialized
68
68
  end
69
69
 
70
+ def reversed
71
+ rev_name = "#{self.name}_r" unless self.name.nil?
72
+ rev = make_reverse_colormap(rev_name)
73
+ rev.over_color = self.over_color
74
+ rev.under_color = self.under_color
75
+ return rev
76
+ end
77
+
78
+ private def make_reverse_colormap(name)
79
+ raise NotImplementedError
80
+ end
81
+
70
82
  PNG_WIDTH = 512
71
83
  PNG_HEIGHT = 64
72
84
 
@@ -0,0 +1,44 @@
1
+ require "json"
2
+ require "pathname"
3
+
4
+ module Colors
5
+ module ColormapRegistry
6
+ BUILTIN_COLORMAPS = {}
7
+ LUT_SIZE = 512
8
+
9
+ top_dir = Pathname.new(__dir__).parent.parent
10
+ @colormaps_dir = top_dir.join("data", "colormaps")
11
+
12
+ def self.load_colormap_data(name)
13
+ path = @colormaps_dir.join("#{name}.json")
14
+ json = File.read(path)
15
+ JSON.load(json, nil, symbolize_names: true, create_additions: false)
16
+ end
17
+
18
+ def self.register_listed_colormap(name, data=nil)
19
+ data = load_colormap_data(name) if data.nil?
20
+ colors = data.map {|r, g, b| Colors::RGB.new(r, g, b) }
21
+ BUILTIN_COLORMAPS[name] = ListedColormap.new(colors, name: name)
22
+ end
23
+
24
+ require_relative "colormap_data/matplotlib_builtin.rb"
25
+ require_relative "colormap_data/seaborn_builtin.rb"
26
+
27
+ class << self
28
+ undef load_colormap_data
29
+ undef register_listed_colormap
30
+ end
31
+
32
+ # Generate reversed colormaps
33
+ cmaps_r = BUILTIN_COLORMAPS.each_value.map(&:reversed)
34
+ cmaps_r.each do |cmap_r|
35
+ BUILTIN_COLORMAPS[cmap_r.name] = cmap_r
36
+ end
37
+
38
+ BUILTIN_COLORMAPS.freeze
39
+
40
+ BUILTIN_COLORMAPS.each do |name, cmap|
41
+ @registry[name] = cmap
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,990 @@
1
+ module Colors
2
+ module ColormapRegistry
3
+ register_listed_colormap("magma")
4
+ register_listed_colormap("inferno")
5
+ register_listed_colormap("plasma")
6
+ register_listed_colormap("viridis")
7
+ register_listed_colormap("cividis")
8
+
9
+ twilight_data = load_colormap_data("twilight")
10
+ register_listed_colormap("twilight", twilight_data)
11
+
12
+ twilight_shifted_data = [*twilight_data[(twilight_data.length/2) .. -1],
13
+ *twilight_data[0 ... (twilight_data.length/2)]]
14
+ twilight_shifted_data.reverse!
15
+ register_listed_colormap("twilight_shifted", twilight_shifted_data)
16
+
17
+ register_listed_colormap("turbo")
18
+
19
+ data = {}
20
+
21
+ data[:binary] = {
22
+ red: [ [0r, 1r, 1r], [1r, 0r, 0r] ],
23
+ green: [ [0r, 1r, 1r], [1r, 0r, 0r] ],
24
+ blue: [ [0r, 1r, 1r], [1r, 0r, 0r] ]
25
+ }
26
+
27
+ data[:autumn] = {
28
+ red: [ [0r, 1r, 1r], [1r, 1r, 1r] ],
29
+ green: [ [0r, 0r, 0r], [1r, 1r, 1r] ],
30
+ blue: [ [0r, 0r, 0r], [1r, 0r, 0r ] ]
31
+ }
32
+
33
+ data[:bone] = {
34
+ red: [ [0r, 0r, 0r],
35
+ [0.746032, 0.652778, 0.652778],
36
+ [1.0, 1.0, 1.0] ],
37
+ green: [ [0r, 0r, 0r],
38
+ [0.365079, 0.319444, 0.319444],
39
+ [0.746032, 0.777778, 0.777778],
40
+ [1.0, 1.0, 1.0] ],
41
+ blue: [ [0r, 0r, 0r],
42
+ [0.365079, 0.444444, 0.444444],
43
+ [1.0, 1.0, 1.0] ]
44
+ }
45
+
46
+ data[:cool] = {
47
+ red: [[0r, 0r, 0r], [1r, 1r, 1r]],
48
+ green: [[0r, 1r, 1r], [1r, 0r, 0r]],
49
+ blue: [[0r, 1r, 1r], [1r, 1r, 1r]]
50
+ }
51
+
52
+ data[:copper] = {
53
+ red: [ [0r, 0r, 0r],
54
+ [0.809524, 1.000000, 1.000000],
55
+ [1.0, 1.0, 1.0]],
56
+ green: [ [0r, 0r, 0r],
57
+ [1.0, 0.7812, 0.7812] ],
58
+ blue: [ [0r, 0r, 0r],
59
+ [1.0, 0.4975, 0.4975] ]
60
+ }
61
+
62
+ data[:flag] = {
63
+ red: ->(x) { 0.75 * Math.sin((x * 31.5 + 0.25) * Math::PI) + 0.5 },
64
+ green: ->(x) { Math.sin(x * 31.5 * Math::PI) },
65
+ blue: ->(x) { 0.75 * Math.sin((x * 31.5 - 0.25) * Math::PI) + 0.5 }
66
+ }
67
+
68
+ data[:prism] = {
69
+ red: ->(x) { 0.75 * Math.sin((x * 20.9 + 0.25) * Math::PI) + 0.67 },
70
+ green: ->(x) { 0.75 * Math.sin((x * 20.9 - 0.25) * Math::PI) + 0.33 },
71
+ blue: ->(x) { -1.1 * Math.sin((x * 20.9) * Math::PI) }
72
+ }
73
+
74
+ cubehelix_color = ->(gamma, s, r, h, p0, p1, x) do
75
+ xg = x ** gamma
76
+ a = h * xg * (1r - xg) / 2r
77
+ phi = 2r * Math::PI * (s / 3r + r * x)
78
+ xg + a * (p0 * Math.cos(phi) + p1 * Math.sin(phi))
79
+ end
80
+
81
+ data[:cubehelix] = {
82
+ red: cubehelix_color.curry[1.0, 0.5, -1.5, 1.0, -0.14861, 1.78277],
83
+ green: cubehelix_color.curry[1.0, 0.5, -1.5, 1.0, -0.29227, -0.90649],
84
+ blue: cubehelix_color.curry[1.0, 0.5, -1.5, 1.0, 1.97294, 0.0]
85
+ }
86
+
87
+ data[:bwr] = [[0.0, 0.0, 1.0], [1.0, 1.0, 1.0], [1.0, 0.0, 0.0]]
88
+ data[:brg] = [[0.0, 0.0, 1.0], [1.0, 0.0, 0.0], [0.0, 1.0, 0.0]]
89
+
90
+ # Gnuplot palette functions
91
+ gnuplot_functions = {
92
+ 0 => ->(x) { 0r },
93
+ 1 => ->(x) { 0.5r },
94
+ 2 => ->(x) { 1r },
95
+ 3 => ->(x) { x },
96
+ 4 => ->(x) { x ** 2 },
97
+ 5 => ->(x) { x ** 3 },
98
+ 6 => ->(x) { x ** 4 },
99
+ 7 => ->(x) { Math.sqrt(x) },
100
+ 8 => ->(x) { Math.sqrt(Math.sqrt(x)) },
101
+ 9 => ->(x) { Math.sin(x * Math::PI / 2) },
102
+ 10 => ->(x) { Math.cos(x * Math::PI / 2) },
103
+ 11 => ->(x) { (x - 0.5).abs },
104
+ 12 => ->(x) { (2 * x - 1) ** 2 },
105
+ 13 => ->(x) { Math.sin(x * Math::PI) },
106
+ 14 => ->(x) { Math.cos(x * Math::PI).abs },
107
+ 15 => ->(x) { Math.sin(x * 2 * Math::PI) },
108
+ 16 => ->(x) { Math.cos(x * 2 * Math::PI) },
109
+ 17 => ->(x) { Math.sin(x * 2 * Math::PI).abs },
110
+ 18 => ->(x) { Math.cos(x * 2 * Math::PI).abs },
111
+ 19 => ->(x) { Math.sin(x * 4 * Math::PI).abs },
112
+ 20 => ->(x) { Math.cos(x * 4 * Math::PI).abs },
113
+ 21 => ->(x) { 3 * x },
114
+ 22 => ->(x) { 3 * x - 1 },
115
+ 23 => ->(x) { 3 * x - 2 },
116
+ 24 => ->(x) { (3 * x - 1).abs },
117
+ 25 => ->(x) { (3 * x - 2).abs },
118
+ 26 => ->(x) { (3 * x - 1) / 2 },
119
+ 27 => ->(x) { (3 * x - 2) / 2 },
120
+ 28 => ->(x) { ((3 * x - 1) / 2).abs },
121
+ 29 => ->(x) { ((3 * x - 2) / 2).abs },
122
+ 30 => ->(x) { x / 0.32 - 0.78125 },
123
+ 31 => ->(x) { 2 * x - 0.84 },
124
+ 32 => ->(x) {
125
+ case
126
+ when x < 0.25
127
+ 4 * x
128
+ when 0.25 <= x && x < 0.92
129
+ -2 * x + 1.84
130
+ when 0.92 <= x
131
+ x / 0.08 - 11.5
132
+ end
133
+ },
134
+ 33 => ->(x) { (2 * x - 0.5).abs },
135
+ 34 => ->(x) { 2 * x },
136
+ 35 => ->(x) { 2 * x - 0.5 },
137
+ 36 => ->(x) { 2 * x - 1 },
138
+ }
139
+
140
+ data[:gnuplot] = {
141
+ red: gnuplot_functions[7],
142
+ green: gnuplot_functions[5],
143
+ blue: gnuplot_functions[15]
144
+ }
145
+
146
+ data[:gnuplot2] = {
147
+ red: gnuplot_functions[30],
148
+ green: gnuplot_functions[31],
149
+ blue: gnuplot_functions[32]
150
+ }
151
+
152
+ data[:ocean] = {
153
+ red: gnuplot_functions[23],
154
+ green: gnuplot_functions[28],
155
+ blue: gnuplot_functions[3]
156
+ }
157
+
158
+ data[:afmhot] = {
159
+ red: gnuplot_functions[34],
160
+ green: gnuplot_functions[35],
161
+ blue: gnuplot_functions[36]
162
+ }
163
+
164
+ data[:rainbow] = {
165
+ red: gnuplot_functions[33],
166
+ green: gnuplot_functions[13],
167
+ blue: gnuplot_functions[10]
168
+ }
169
+
170
+ data[:seismic] = [
171
+ [0.0, 0.0, 0.3],
172
+ [0.0, 0.0, 1.0],
173
+ [1.0, 1.0, 1.0],
174
+ [1.0, 0.0, 0.0],
175
+ [0.5, 0.0, 0.0]
176
+ ]
177
+
178
+ data[:terrain] = [
179
+ [0.00, [0.2, 0.2, 0.6]],
180
+ [0.15, [0.0, 0.6, 1.0]],
181
+ [0.25, [0.0, 0.8, 0.4]],
182
+ [0.50, [1.0, 1.0, 0.6]],
183
+ [0.75, [0.5, 0.36, 0.33]],
184
+ [1.00, [1.0, 1.0, 1.0]]
185
+ ]
186
+
187
+ data[:gray] = {
188
+ red: [[0r, 0r, 0r], [1r, 1r, 1r]],
189
+ green: [[0r, 0r, 0r], [1r, 1r, 1r]],
190
+ blue: [[0r, 0r, 0r], [1r, 1r, 1r]]
191
+ }
192
+
193
+ data[:hot] = {
194
+ red: [ [0r, 0.0416, 0.0416],
195
+ [0.365079, 1.000000, 1.000000],
196
+ [1.0, 1.0, 1.0] ],
197
+ green: [ [0r, 0r, 0r],
198
+ [0.365079, 0.000000, 0.000000],
199
+ [0.746032, 1.000000, 1.000000],
200
+ [1.0, 1.0, 1.0] ],
201
+ blue: [ [0r, 0r, 0r],
202
+ [0.746032, 0.000000, 0.000000],
203
+ [1.0, 1.0, 1.0] ]
204
+ }
205
+
206
+ data[:hsv] = {
207
+ red: [ [0r, 1r, 1r],
208
+ [0.158730, 1.000000, 1.000000],
209
+ [0.174603, 0.968750, 0.968750],
210
+ [0.333333, 0.031250, 0.031250],
211
+ [0.349206, 0.000000, 0.000000],
212
+ [0.666667, 0.000000, 0.000000],
213
+ [0.682540, 0.031250, 0.031250],
214
+ [0.841270, 0.968750, 0.968750],
215
+ [0.857143, 1.000000, 1.000000],
216
+ [1.0, 1.0, 1.0] ],
217
+ green: [ [0r, 0r, 0r],
218
+ [0.158730, 0.937500, 0.937500],
219
+ [0.174603, 1.000000, 1.000000],
220
+ [0.507937, 1.000000, 1.000000],
221
+ [0.666667, 0.062500, 0.062500],
222
+ [0.682540, 0.000000, 0.000000],
223
+ [1r, 0r, 0r] ],
224
+ blue: [ [0r, 0r, 0r],
225
+ [0.333333, 0.000000, 0.000000],
226
+ [0.349206, 0.062500, 0.062500],
227
+ [0.507937, 1.000000, 1.000000],
228
+ [0.841270, 1.000000, 1.000000],
229
+ [0.857143, 0.937500, 0.937500],
230
+ [1.0, 0.09375, 0.09375] ]
231
+ }
232
+
233
+ data[:jet] = {
234
+ red: [ [0.00, 0r, 0r],
235
+ [0.35, 0r, 0r],
236
+ [0.66, 1r, 1r],
237
+ [0.89, 1r, 1r],
238
+ [1.00, 0.5, 0.5] ],
239
+ green: [ [0.000, 0r, 0r],
240
+ [0.125, 0r, 0r],
241
+ [0.375, 1r, 1r],
242
+ [0.640, 1r, 1r],
243
+ [0.910, 0r, 0r],
244
+ [1.000, 0r, 0r] ],
245
+ blue: [ [0.00, 0.5, 0.5],
246
+ [0.11, 1r, 1r],
247
+ [0.34, 1r, 1r],
248
+ [0.65, 0r, 0r],
249
+ [1.00, 0r, 0r] ]
250
+ }
251
+
252
+ data[:pink] = load_colormap_data("pink")
253
+
254
+ data[:spring] = {
255
+ red: [[0r, 1r, 1r], [1.0, 1.0, 1.0]],
256
+ green: [[0r, 0r, 0r], [1.0, 1.0, 1.0]],
257
+ blue: [[0r, 1r, 1r], [1.0, 0.0, 0.0]]
258
+ }
259
+
260
+ data[:summer] = {
261
+ red: [[0r, 0r, 0r ], [1.0, 1.0, 1.0]],
262
+ green: [[0r, 0.5, 0.5], [1.0, 1.0, 1.0]],
263
+ blue: [[0r, 0.4, 0.4], [1.0, 0.4, 0.4]]
264
+ }
265
+
266
+ data[:winter] = {
267
+ red: [[0r, 0r, 0r], [1.0, 0.0, 0.0]],
268
+ green: [[0r, 0r, 0r], [1.0, 1.0, 1.0]],
269
+ blue: [[0r, 1r, 1r], [1.0, 0.5, 0.5]]
270
+ }
271
+
272
+ data[:nipy_spectral] = load_colormap_data("nipy_spectral")
273
+
274
+ # 34 colormaps based on color specifications and designs
275
+ # developed by Cynthia Brewer (http://colorbrewer.org).
276
+ # The ColorBrewer palettes have been included under the terms
277
+ # of an Apache-stype license (for details, see the file
278
+ # LICENSE_COLORBREWER in the license directory of the matplotlib
279
+ # source distribution).
280
+
281
+ # RGB values taken from Brewer's Excel sheet, divided by 255
282
+
283
+ data[:Blues] = [
284
+ [0.96862745098039216, 0.98431372549019602, 1.0 ],
285
+ [0.87058823529411766, 0.92156862745098034, 0.96862745098039216],
286
+ [0.77647058823529413, 0.85882352941176465, 0.93725490196078431],
287
+ [0.61960784313725492, 0.792156862745098 , 0.88235294117647056],
288
+ [0.41960784313725491, 0.68235294117647061, 0.83921568627450982],
289
+ [0.25882352941176473, 0.5725490196078431 , 0.77647058823529413],
290
+ [0.12941176470588237, 0.44313725490196076, 0.70980392156862748],
291
+ [0.03137254901960784, 0.31764705882352939, 0.61176470588235299],
292
+ [0.03137254901960784, 0.18823529411764706, 0.41960784313725491]
293
+ ]
294
+
295
+ data[:BrBG] = [
296
+ [0.32941176470588235, 0.18823529411764706, 0.0196078431372549 ],
297
+ [0.5490196078431373 , 0.31764705882352939, 0.0392156862745098 ],
298
+ [0.74901960784313726, 0.50588235294117645, 0.17647058823529413],
299
+ [0.87450980392156863, 0.76078431372549016, 0.49019607843137253],
300
+ [0.96470588235294119, 0.90980392156862744, 0.76470588235294112],
301
+ [0.96078431372549022, 0.96078431372549022, 0.96078431372549022],
302
+ [0.7803921568627451 , 0.91764705882352937, 0.89803921568627454],
303
+ [0.50196078431372548, 0.80392156862745101, 0.75686274509803919],
304
+ [0.20784313725490197, 0.59215686274509804, 0.5607843137254902 ],
305
+ [0.00392156862745098, 0.4 , 0.36862745098039218],
306
+ [0.0 , 0.23529411764705882, 0.18823529411764706]
307
+ ]
308
+
309
+ data[:BuGn] = [
310
+ [0.96862745098039216, 0.9882352941176471 , 0.99215686274509807],
311
+ [0.89803921568627454, 0.96078431372549022, 0.97647058823529409],
312
+ [0.8 , 0.92549019607843142, 0.90196078431372551],
313
+ [0.6 , 0.84705882352941175, 0.78823529411764703],
314
+ [0.4 , 0.76078431372549016, 0.64313725490196083],
315
+ [0.25490196078431371, 0.68235294117647061, 0.46274509803921571],
316
+ [0.13725490196078433, 0.54509803921568623, 0.27058823529411763],
317
+ [0.0 , 0.42745098039215684, 0.17254901960784313],
318
+ [0.0 , 0.26666666666666666, 0.10588235294117647]
319
+ ]
320
+
321
+ data[:BuPu] = [
322
+ [0.96862745098039216, 0.9882352941176471 , 0.99215686274509807],
323
+ [0.8784313725490196 , 0.92549019607843142, 0.95686274509803926],
324
+ [0.74901960784313726, 0.82745098039215681, 0.90196078431372551],
325
+ [0.61960784313725492, 0.73725490196078436, 0.85490196078431369],
326
+ [0.5490196078431373 , 0.58823529411764708, 0.77647058823529413],
327
+ [0.5490196078431373 , 0.41960784313725491, 0.69411764705882351],
328
+ [0.53333333333333333, 0.25490196078431371, 0.61568627450980395],
329
+ [0.50588235294117645, 0.05882352941176471, 0.48627450980392156],
330
+ [0.30196078431372547, 0.0 , 0.29411764705882354]
331
+ ]
332
+
333
+ data[:GnBu] = [
334
+ [0.96862745098039216, 0.9882352941176471 , 0.94117647058823528],
335
+ [0.8784313725490196 , 0.95294117647058818, 0.85882352941176465],
336
+ [0.8 , 0.92156862745098034, 0.77254901960784317],
337
+ [0.6588235294117647 , 0.8666666666666667 , 0.70980392156862748],
338
+ [0.4823529411764706 , 0.8 , 0.7686274509803922 ],
339
+ [0.30588235294117649, 0.70196078431372544, 0.82745098039215681],
340
+ [0.16862745098039217, 0.5490196078431373 , 0.74509803921568629],
341
+ [0.03137254901960784, 0.40784313725490196, 0.67450980392156867],
342
+ [0.03137254901960784, 0.25098039215686274, 0.50588235294117645]
343
+ ]
344
+
345
+ data[:Greens] = [
346
+ [0.96862745098039216, 0.9882352941176471 , 0.96078431372549022],
347
+ [0.89803921568627454, 0.96078431372549022, 0.8784313725490196 ],
348
+ [0.7803921568627451 , 0.9137254901960784 , 0.75294117647058822],
349
+ [0.63137254901960782, 0.85098039215686272, 0.60784313725490191],
350
+ [0.45490196078431372, 0.7686274509803922 , 0.46274509803921571],
351
+ [0.25490196078431371, 0.6705882352941176 , 0.36470588235294116],
352
+ [0.13725490196078433, 0.54509803921568623, 0.27058823529411763],
353
+ [0.0 , 0.42745098039215684, 0.17254901960784313],
354
+ [0.0 , 0.26666666666666666, 0.10588235294117647]
355
+ ]
356
+
357
+ data[:Greys] = [
358
+ [1.0 , 1.0 , 1.0 ],
359
+ [0.94117647058823528, 0.94117647058823528, 0.94117647058823528],
360
+ [0.85098039215686272, 0.85098039215686272, 0.85098039215686272],
361
+ [0.74117647058823533, 0.74117647058823533, 0.74117647058823533],
362
+ [0.58823529411764708, 0.58823529411764708, 0.58823529411764708],
363
+ [0.45098039215686275, 0.45098039215686275, 0.45098039215686275],
364
+ [0.32156862745098042, 0.32156862745098042, 0.32156862745098042],
365
+ [0.14509803921568629, 0.14509803921568629, 0.14509803921568629],
366
+ [0.0 , 0.0 , 0.0 ]
367
+ ]
368
+
369
+ data[:OrRd] = [
370
+ [1.0 , 0.96862745098039216, 0.92549019607843142],
371
+ [0.99607843137254903, 0.90980392156862744, 0.78431372549019607],
372
+ [0.99215686274509807, 0.83137254901960789, 0.61960784313725492],
373
+ [0.99215686274509807, 0.73333333333333328, 0.51764705882352946],
374
+ [0.9882352941176471 , 0.55294117647058827, 0.34901960784313724],
375
+ [0.93725490196078431, 0.396078431372549 , 0.28235294117647058],
376
+ [0.84313725490196079, 0.18823529411764706, 0.12156862745098039],
377
+ [0.70196078431372544, 0.0 , 0.0 ],
378
+ [0.49803921568627452, 0.0 , 0.0 ]
379
+ ]
380
+
381
+ data[:Oranges] = [
382
+ [1.0 , 0.96078431372549022, 0.92156862745098034],
383
+ [0.99607843137254903, 0.90196078431372551, 0.80784313725490198],
384
+ [0.99215686274509807, 0.81568627450980391, 0.63529411764705879],
385
+ [0.99215686274509807, 0.68235294117647061, 0.41960784313725491],
386
+ [0.99215686274509807, 0.55294117647058827, 0.23529411764705882],
387
+ [0.94509803921568625, 0.41176470588235292, 0.07450980392156863],
388
+ [0.85098039215686272, 0.28235294117647058, 0.00392156862745098],
389
+ [0.65098039215686276, 0.21176470588235294, 0.01176470588235294],
390
+ [0.49803921568627452, 0.15294117647058825, 0.01568627450980392]
391
+ ]
392
+
393
+ data[:PRGn] = [
394
+ [0.25098039215686274, 0.0 , 0.29411764705882354],
395
+ [0.46274509803921571, 0.16470588235294117, 0.51372549019607838],
396
+ [0.6 , 0.4392156862745098 , 0.6705882352941176 ],
397
+ [0.76078431372549016, 0.6470588235294118 , 0.81176470588235294],
398
+ [0.90588235294117647, 0.83137254901960789, 0.90980392156862744],
399
+ [0.96862745098039216, 0.96862745098039216, 0.96862745098039216],
400
+ [0.85098039215686272, 0.94117647058823528, 0.82745098039215681],
401
+ [0.65098039215686276, 0.85882352941176465, 0.62745098039215685],
402
+ [0.35294117647058826, 0.68235294117647061, 0.38039215686274508],
403
+ [0.10588235294117647, 0.47058823529411764, 0.21568627450980393],
404
+ [0.0 , 0.26666666666666666, 0.10588235294117647]
405
+ ]
406
+
407
+ data[:PiYG] = [
408
+ [0.55686274509803924, 0.00392156862745098, 0.32156862745098042],
409
+ [0.77254901960784317, 0.10588235294117647, 0.49019607843137253],
410
+ [0.87058823529411766, 0.46666666666666667, 0.68235294117647061],
411
+ [0.94509803921568625, 0.71372549019607845, 0.85490196078431369],
412
+ [0.99215686274509807, 0.8784313725490196 , 0.93725490196078431],
413
+ [0.96862745098039216, 0.96862745098039216, 0.96862745098039216],
414
+ [0.90196078431372551, 0.96078431372549022, 0.81568627450980391],
415
+ [0.72156862745098038, 0.88235294117647056, 0.52549019607843139],
416
+ [0.49803921568627452, 0.73725490196078436, 0.25490196078431371],
417
+ [0.30196078431372547, 0.5725490196078431 , 0.12941176470588237],
418
+ [0.15294117647058825, 0.39215686274509803, 0.09803921568627451]
419
+ ]
420
+
421
+ data[:PuBu] = [
422
+ [1.0 , 0.96862745098039216, 0.98431372549019602],
423
+ [0.92549019607843142, 0.90588235294117647, 0.94901960784313721],
424
+ [0.81568627450980391, 0.81960784313725488, 0.90196078431372551],
425
+ [0.65098039215686276, 0.74117647058823533, 0.85882352941176465],
426
+ [0.45490196078431372, 0.66274509803921566, 0.81176470588235294],
427
+ [0.21176470588235294, 0.56470588235294117, 0.75294117647058822],
428
+ [0.0196078431372549 , 0.4392156862745098 , 0.69019607843137254],
429
+ [0.01568627450980392, 0.35294117647058826, 0.55294117647058827],
430
+ [0.00784313725490196, 0.2196078431372549 , 0.34509803921568627]
431
+ ]
432
+
433
+ data[:PuBuGn] = [
434
+ [1.0 , 0.96862745098039216, 0.98431372549019602],
435
+ [0.92549019607843142, 0.88627450980392153, 0.94117647058823528],
436
+ [0.81568627450980391, 0.81960784313725488, 0.90196078431372551],
437
+ [0.65098039215686276, 0.74117647058823533, 0.85882352941176465],
438
+ [0.40392156862745099, 0.66274509803921566, 0.81176470588235294],
439
+ [0.21176470588235294, 0.56470588235294117, 0.75294117647058822],
440
+ [0.00784313725490196, 0.50588235294117645, 0.54117647058823526],
441
+ [0.00392156862745098, 0.42352941176470588, 0.34901960784313724],
442
+ [0.00392156862745098, 0.27450980392156865, 0.21176470588235294]
443
+ ]
444
+
445
+ data[:PuOr] = [
446
+ [0.49803921568627452, 0.23137254901960785, 0.03137254901960784],
447
+ [0.70196078431372544, 0.34509803921568627, 0.02352941176470588],
448
+ [0.8784313725490196 , 0.50980392156862742, 0.07843137254901961],
449
+ [0.99215686274509807, 0.72156862745098038, 0.38823529411764707],
450
+ [0.99607843137254903, 0.8784313725490196 , 0.71372549019607845],
451
+ [0.96862745098039216, 0.96862745098039216, 0.96862745098039216],
452
+ [0.84705882352941175, 0.85490196078431369, 0.92156862745098034],
453
+ [0.69803921568627447, 0.6705882352941176 , 0.82352941176470584],
454
+ [0.50196078431372548, 0.45098039215686275, 0.67450980392156867],
455
+ [0.32941176470588235, 0.15294117647058825, 0.53333333333333333],
456
+ [0.17647058823529413, 0.0 , 0.29411764705882354]
457
+ ]
458
+
459
+ data[:PuRd] = [
460
+ [0.96862745098039216, 0.95686274509803926, 0.97647058823529409],
461
+ [0.90588235294117647, 0.88235294117647056, 0.93725490196078431],
462
+ [0.83137254901960789, 0.72549019607843135, 0.85490196078431369],
463
+ [0.78823529411764703, 0.58039215686274515, 0.7803921568627451 ],
464
+ [0.87450980392156863, 0.396078431372549 , 0.69019607843137254],
465
+ [0.90588235294117647, 0.16078431372549021, 0.54117647058823526],
466
+ [0.80784313725490198, 0.07058823529411765, 0.33725490196078434],
467
+ [0.59607843137254901, 0.0 , 0.2627450980392157 ],
468
+ [0.40392156862745099, 0.0 , 0.12156862745098039]
469
+ ]
470
+
471
+ data[:Purples] = [
472
+ [0.9882352941176471 , 0.98431372549019602, 0.99215686274509807],
473
+ [0.93725490196078431, 0.92941176470588238, 0.96078431372549022],
474
+ [0.85490196078431369, 0.85490196078431369, 0.92156862745098034],
475
+ [0.73725490196078436, 0.74117647058823533, 0.86274509803921573],
476
+ [0.61960784313725492, 0.60392156862745094, 0.78431372549019607],
477
+ [0.50196078431372548, 0.49019607843137253, 0.72941176470588232],
478
+ [0.41568627450980394, 0.31764705882352939, 0.63921568627450975],
479
+ [0.32941176470588235, 0.15294117647058825, 0.5607843137254902 ],
480
+ [0.24705882352941178, 0.0 , 0.49019607843137253]
481
+ ]
482
+
483
+ data[:RdBu] = [
484
+ [0.40392156862745099, 0.0 , 0.12156862745098039],
485
+ [0.69803921568627447, 0.09411764705882353, 0.16862745098039217],
486
+ [0.83921568627450982, 0.37647058823529411, 0.30196078431372547],
487
+ [0.95686274509803926, 0.6470588235294118 , 0.50980392156862742],
488
+ [0.99215686274509807, 0.85882352941176465, 0.7803921568627451 ],
489
+ [0.96862745098039216, 0.96862745098039216, 0.96862745098039216],
490
+ [0.81960784313725488, 0.89803921568627454, 0.94117647058823528],
491
+ [0.5725490196078431 , 0.77254901960784317, 0.87058823529411766],
492
+ [0.2627450980392157 , 0.57647058823529407, 0.76470588235294112],
493
+ [0.12941176470588237, 0.4 , 0.67450980392156867],
494
+ [0.0196078431372549 , 0.18823529411764706, 0.38039215686274508]
495
+ ]
496
+
497
+ data[:RdGy] = [
498
+ [0.40392156862745099, 0.0 , 0.12156862745098039],
499
+ [0.69803921568627447, 0.09411764705882353, 0.16862745098039217],
500
+ [0.83921568627450982, 0.37647058823529411, 0.30196078431372547],
501
+ [0.95686274509803926, 0.6470588235294118 , 0.50980392156862742],
502
+ [0.99215686274509807, 0.85882352941176465, 0.7803921568627451 ],
503
+ [1.0 , 1.0 , 1.0 ],
504
+ [0.8784313725490196 , 0.8784313725490196 , 0.8784313725490196 ],
505
+ [0.72941176470588232, 0.72941176470588232, 0.72941176470588232],
506
+ [0.52941176470588236, 0.52941176470588236, 0.52941176470588236],
507
+ [0.30196078431372547, 0.30196078431372547, 0.30196078431372547],
508
+ [0.10196078431372549, 0.10196078431372549, 0.10196078431372549]
509
+ ]
510
+
511
+ data[:RdPu] = [
512
+ [1.0 , 0.96862745098039216, 0.95294117647058818],
513
+ [0.99215686274509807, 0.8784313725490196 , 0.86666666666666667],
514
+ [0.9882352941176471 , 0.77254901960784317, 0.75294117647058822],
515
+ [0.98039215686274506, 0.62352941176470589, 0.70980392156862748],
516
+ [0.96862745098039216, 0.40784313725490196, 0.63137254901960782],
517
+ [0.86666666666666667, 0.20392156862745098, 0.59215686274509804],
518
+ [0.68235294117647061, 0.00392156862745098, 0.49411764705882355],
519
+ [0.47843137254901963, 0.00392156862745098, 0.46666666666666667],
520
+ [0.28627450980392155, 0.0 , 0.41568627450980394]
521
+ ]
522
+
523
+ data[:RdYlBu] = [
524
+ [0.6470588235294118 , 0.0 , 0.14901960784313725],
525
+ [0.84313725490196079, 0.18823529411764706 , 0.15294117647058825],
526
+ [0.95686274509803926, 0.42745098039215684 , 0.2627450980392157 ],
527
+ [0.99215686274509807, 0.68235294117647061 , 0.38039215686274508],
528
+ [0.99607843137254903, 0.8784313725490196 , 0.56470588235294117],
529
+ [1.0 , 1.0 , 0.74901960784313726],
530
+ [0.8784313725490196 , 0.95294117647058818 , 0.97254901960784312],
531
+ [0.6705882352941176 , 0.85098039215686272 , 0.9137254901960784 ],
532
+ [0.45490196078431372, 0.67843137254901964 , 0.81960784313725488],
533
+ [0.27058823529411763, 0.45882352941176469 , 0.70588235294117652],
534
+ [0.19215686274509805, 0.21176470588235294 , 0.58431372549019611]
535
+ ]
536
+
537
+ data[:RdYlGn] = [
538
+ [0.6470588235294118 , 0.0 , 0.14901960784313725],
539
+ [0.84313725490196079, 0.18823529411764706 , 0.15294117647058825],
540
+ [0.95686274509803926, 0.42745098039215684 , 0.2627450980392157 ],
541
+ [0.99215686274509807, 0.68235294117647061 , 0.38039215686274508],
542
+ [0.99607843137254903, 0.8784313725490196 , 0.54509803921568623],
543
+ [1.0 , 1.0 , 0.74901960784313726],
544
+ [0.85098039215686272, 0.93725490196078431 , 0.54509803921568623],
545
+ [0.65098039215686276, 0.85098039215686272 , 0.41568627450980394],
546
+ [0.4 , 0.74117647058823533 , 0.38823529411764707],
547
+ [0.10196078431372549, 0.59607843137254901 , 0.31372549019607843],
548
+ [0.0 , 0.40784313725490196 , 0.21568627450980393]
549
+ ]
550
+
551
+ data[:Reds] = [
552
+ [1.0 , 0.96078431372549022 , 0.94117647058823528],
553
+ [0.99607843137254903, 0.8784313725490196 , 0.82352941176470584],
554
+ [0.9882352941176471 , 0.73333333333333328 , 0.63137254901960782],
555
+ [0.9882352941176471 , 0.5725490196078431 , 0.44705882352941179],
556
+ [0.98431372549019602, 0.41568627450980394 , 0.29019607843137257],
557
+ [0.93725490196078431, 0.23137254901960785 , 0.17254901960784313],
558
+ [0.79607843137254897, 0.094117647058823528, 0.11372549019607843],
559
+ [0.6470588235294118 , 0.058823529411764705, 0.08235294117647058],
560
+ [0.40392156862745099, 0.0 , 0.05098039215686274]
561
+ ]
562
+
563
+ data[:Spectral] = [
564
+ [0.61960784313725492, 0.003921568627450980, 0.25882352941176473],
565
+ [0.83529411764705885, 0.24313725490196078 , 0.30980392156862746],
566
+ [0.95686274509803926, 0.42745098039215684 , 0.2627450980392157 ],
567
+ [0.99215686274509807, 0.68235294117647061 , 0.38039215686274508],
568
+ [0.99607843137254903, 0.8784313725490196 , 0.54509803921568623],
569
+ [1.0 , 1.0 , 0.74901960784313726],
570
+ [0.90196078431372551, 0.96078431372549022 , 0.59607843137254901],
571
+ [0.6705882352941176 , 0.8666666666666667 , 0.64313725490196083],
572
+ [0.4 , 0.76078431372549016 , 0.6470588235294118 ],
573
+ [0.19607843137254902, 0.53333333333333333 , 0.74117647058823533],
574
+ [0.36862745098039218, 0.30980392156862746 , 0.63529411764705879]
575
+ ]
576
+
577
+ data[:YlGn] = [
578
+ [1.0 , 1.0 , 0.89803921568627454],
579
+ [0.96862745098039216, 0.9882352941176471 , 0.72549019607843135],
580
+ [0.85098039215686272, 0.94117647058823528 , 0.63921568627450975],
581
+ [0.67843137254901964, 0.8666666666666667 , 0.55686274509803924],
582
+ [0.47058823529411764, 0.77647058823529413 , 0.47450980392156861],
583
+ [0.25490196078431371, 0.6705882352941176 , 0.36470588235294116],
584
+ [0.13725490196078433, 0.51764705882352946 , 0.2627450980392157 ],
585
+ [0.0 , 0.40784313725490196 , 0.21568627450980393],
586
+ [0.0 , 0.27058823529411763 , 0.16078431372549021]
587
+ ]
588
+
589
+ data[:YlGnBu] = [
590
+ [1.0 , 1.0 , 0.85098039215686272],
591
+ [0.92941176470588238, 0.97254901960784312 , 0.69411764705882351],
592
+ [0.7803921568627451 , 0.9137254901960784 , 0.70588235294117652],
593
+ [0.49803921568627452, 0.80392156862745101 , 0.73333333333333328],
594
+ [0.25490196078431371, 0.71372549019607845 , 0.7686274509803922 ],
595
+ [0.11372549019607843, 0.56862745098039214 , 0.75294117647058822],
596
+ [0.13333333333333333, 0.36862745098039218 , 0.6588235294117647 ],
597
+ [0.14509803921568629, 0.20392156862745098 , 0.58039215686274515],
598
+ [0.03137254901960784, 0.11372549019607843 , 0.34509803921568627]
599
+ ]
600
+
601
+ data[:YlOrBr] = [
602
+ [1.0 , 1.0 , 0.89803921568627454],
603
+ [1.0 , 0.96862745098039216 , 0.73725490196078436],
604
+ [0.99607843137254903, 0.8901960784313725 , 0.56862745098039214],
605
+ [0.99607843137254903, 0.7686274509803922 , 0.30980392156862746],
606
+ [0.99607843137254903, 0.6 , 0.16078431372549021],
607
+ [0.92549019607843142, 0.4392156862745098 , 0.07843137254901961],
608
+ [0.8 , 0.29803921568627451 , 0.00784313725490196],
609
+ [0.6 , 0.20392156862745098 , 0.01568627450980392],
610
+ [0.4 , 0.14509803921568629 , 0.02352941176470588]
611
+ ]
612
+
613
+ data[:YlOrRd] = [
614
+ [1.0 , 1.0 , 0.8 ],
615
+ [1.0 , 0.92941176470588238 , 0.62745098039215685],
616
+ [0.99607843137254903, 0.85098039215686272 , 0.46274509803921571],
617
+ [0.99607843137254903, 0.69803921568627447 , 0.29803921568627451],
618
+ [0.99215686274509807, 0.55294117647058827 , 0.23529411764705882],
619
+ [0.9882352941176471 , 0.30588235294117649 , 0.16470588235294117],
620
+ [0.8901960784313725 , 0.10196078431372549 , 0.10980392156862745],
621
+ [0.74117647058823533, 0.0 , 0.14901960784313725],
622
+ [0.50196078431372548, 0.0 , 0.14901960784313725]
623
+ ]
624
+
625
+ # ColorBrewer's qualitative maps, implemented using ListedColormap
626
+ # for use with mpl.colors.NoNorm
627
+
628
+ data[:Accent] = {listed: [
629
+ [0.49803921568627452, 0.78823529411764703, 0.49803921568627452],
630
+ [0.74509803921568629, 0.68235294117647061, 0.83137254901960789],
631
+ [0.99215686274509807, 0.75294117647058822, 0.52549019607843139],
632
+ [1.0, 1.0, 0.6 ],
633
+ [0.2196078431372549, 0.42352941176470588, 0.69019607843137254],
634
+ [0.94117647058823528, 0.00784313725490196, 0.49803921568627452],
635
+ [0.74901960784313726, 0.35686274509803922, 0.09019607843137254],
636
+ [0.4, 0.4, 0.4 ]
637
+ ]}
638
+
639
+ data[:Dark2] = {listed: [
640
+ [0.10588235294117647, 0.61960784313725492, 0.46666666666666667],
641
+ [0.85098039215686272, 0.37254901960784315, 0.00784313725490196],
642
+ [0.45882352941176469, 0.4392156862745098, 0.70196078431372544],
643
+ [0.90588235294117647, 0.16078431372549021, 0.54117647058823526],
644
+ [0.4, 0.65098039215686276, 0.11764705882352941],
645
+ [0.90196078431372551, 0.6705882352941176, 0.00784313725490196],
646
+ [0.65098039215686276, 0.46274509803921571, 0.11372549019607843],
647
+ [0.4, 0.4, 0.4 ]
648
+ ]}
649
+
650
+ data[:Paired] = {listed: [
651
+ [0.65098039215686276, 0.80784313725490198, 0.8901960784313725 ],
652
+ [0.12156862745098039, 0.47058823529411764, 0.70588235294117652],
653
+ [0.69803921568627447, 0.87450980392156863, 0.54117647058823526],
654
+ [0.2, 0.62745098039215685, 0.17254901960784313],
655
+ [0.98431372549019602, 0.60392156862745094, 0.6 ],
656
+ [0.8901960784313725, 0.10196078431372549, 0.10980392156862745],
657
+ [0.99215686274509807, 0.74901960784313726, 0.43529411764705883],
658
+ [1.0, 0.49803921568627452, 0.0 ],
659
+ [0.792156862745098, 0.69803921568627447, 0.83921568627450982],
660
+ [0.41568627450980394, 0.23921568627450981, 0.60392156862745094],
661
+ [1.0, 1.0, 0.6 ],
662
+ [0.69411764705882351, 0.34901960784313724, 0.15686274509803921]
663
+ ]}
664
+
665
+ data[:Pastel1] = {listed: [
666
+ [0.98431372549019602, 0.70588235294117652, 0.68235294117647061],
667
+ [0.70196078431372544, 0.80392156862745101, 0.8901960784313725 ],
668
+ [0.8, 0.92156862745098034, 0.77254901960784317],
669
+ [0.87058823529411766, 0.79607843137254897, 0.89411764705882357],
670
+ [0.99607843137254903, 0.85098039215686272, 0.65098039215686276],
671
+ [1.0, 1.0, 0.8 ],
672
+ [0.89803921568627454, 0.84705882352941175, 0.74117647058823533],
673
+ [0.99215686274509807, 0.85490196078431369, 0.92549019607843142],
674
+ [0.94901960784313721, 0.94901960784313721, 0.94901960784313721]
675
+ ]}
676
+
677
+ data[:Pastel2] = {listed: [
678
+ [0.70196078431372544, 0.88627450980392153, 0.80392156862745101],
679
+ [0.99215686274509807, 0.80392156862745101, 0.67450980392156867],
680
+ [0.79607843137254897, 0.83529411764705885, 0.90980392156862744],
681
+ [0.95686274509803926, 0.792156862745098, 0.89411764705882357],
682
+ [0.90196078431372551, 0.96078431372549022, 0.78823529411764703],
683
+ [1.0, 0.94901960784313721, 0.68235294117647061],
684
+ [0.94509803921568625, 0.88627450980392153, 0.8 ],
685
+ [0.8, 0.8, 0.8 ]
686
+ ]}
687
+
688
+ data[:Set1] = {listed: [
689
+ [0.89411764705882357, 0.10196078431372549, 0.10980392156862745],
690
+ [0.21568627450980393, 0.49411764705882355, 0.72156862745098038],
691
+ [0.30196078431372547, 0.68627450980392157, 0.29019607843137257],
692
+ [0.59607843137254901, 0.30588235294117649, 0.63921568627450975],
693
+ [1.0, 0.49803921568627452, 0.0 ],
694
+ [1.0, 1.0, 0.2 ],
695
+ [0.65098039215686276, 0.33725490196078434, 0.15686274509803921],
696
+ [0.96862745098039216, 0.50588235294117645, 0.74901960784313726],
697
+ [0.6, 0.6, 0.6 ]
698
+ ]}
699
+
700
+ data[:Set2] = {listed: [
701
+ [0.4, 0.76078431372549016, 0.6470588235294118 ],
702
+ [0.9882352941176471, 0.55294117647058827, 0.3843137254901961 ],
703
+ [0.55294117647058827, 0.62745098039215685, 0.79607843137254897],
704
+ [0.90588235294117647, 0.54117647058823526, 0.76470588235294112],
705
+ [0.65098039215686276, 0.84705882352941175, 0.32941176470588235],
706
+ [1.0, 0.85098039215686272, 0.18431372549019609],
707
+ [0.89803921568627454, 0.7686274509803922, 0.58039215686274515],
708
+ [0.70196078431372544, 0.70196078431372544, 0.70196078431372544]
709
+ ]}
710
+
711
+ data[:Set3] = {listed: [
712
+ [0.55294117647058827, 0.82745098039215681, 0.7803921568627451 ],
713
+ [1.0, 1.0, 0.70196078431372544],
714
+ [0.74509803921568629, 0.72941176470588232, 0.85490196078431369],
715
+ [0.98431372549019602, 0.50196078431372548, 0.44705882352941179],
716
+ [0.50196078431372548, 0.69411764705882351, 0.82745098039215681],
717
+ [0.99215686274509807, 0.70588235294117652, 0.3843137254901961 ],
718
+ [0.70196078431372544, 0.87058823529411766, 0.41176470588235292],
719
+ [0.9882352941176471, 0.80392156862745101, 0.89803921568627454],
720
+ [0.85098039215686272, 0.85098039215686272, 0.85098039215686272],
721
+ [0.73725490196078436, 0.50196078431372548, 0.74117647058823533],
722
+ [0.8, 0.92156862745098034, 0.77254901960784317],
723
+ [1.0, 0.92941176470588238, 0.43529411764705883]
724
+ ]}
725
+
726
+ # The next 7 palettes are from the Yorick scientific visualization package,
727
+ # an evolution of the GIST package, both by David H. Munro.
728
+ # They are released under a BSD-like license (see LICENSE_YORICK in
729
+ # the license directory of the matplotlib source distribution).
730
+ #
731
+ # Most palette functions have been reduced to simple function descriptions
732
+ # by Reinier Heeres, since the rgb components were mostly straight lines.
733
+ # gist_earth_data and gist_ncar_data were simplified by a script and some
734
+ # manual effort.
735
+
736
+ data[:gist_earth] = load_colormap_data("gist_earth")
737
+
738
+ data[:gist_gray] = {
739
+ red: gnuplot_functions[3],
740
+ green: gnuplot_functions[3],
741
+ blue: gnuplot_functions[3]
742
+ }
743
+
744
+ data[:gist_heat] = {
745
+ red: ->(x) { 1.5 * x },
746
+ green: ->(x) { 2 * x - 1 },
747
+ blue: ->(x) { 4 * x - 3 }
748
+ }
749
+
750
+ data[:gist_ncar] = load_colormap_data("gist_ncar")
751
+
752
+ data[:gist_rainbow] = [
753
+ [0.000, [1.00, 0.00, 0.16]],
754
+ [0.030, [1.00, 0.00, 0.00]],
755
+ [0.215, [1.00, 1.00, 0.00]],
756
+ [0.400, [0.00, 1.00, 0.00]],
757
+ [0.586, [0.00, 1.00, 1.00]],
758
+ [0.770, [0.00, 0.00, 1.00]],
759
+ [0.954, [1.00, 0.00, 1.00]],
760
+ [1.000, [1.00, 0.00, 0.75]]
761
+ ]
762
+
763
+ data[:gist_stern] = {
764
+ 'red': [
765
+ [0.000, 0.000, 0.000],
766
+ [0.0547, 1.000, 1.000],
767
+ [0.250, 0.027, 0.250],
768
+ # [0.2500, 0.250, 0.250],
769
+ [1.000, 1.000, 1.000]
770
+ ],
771
+ 'green': [
772
+ [0r, 0r, 0r],
773
+ [1r, 1r, 1r]
774
+ ],
775
+ 'blue': [
776
+ [0.000, 0.000, 0.000],
777
+ [0.500, 1.000, 1.000],
778
+ [0.735, 0.000, 0.000],
779
+ [1.000, 1.000, 1.000]
780
+ ]
781
+ }
782
+
783
+ data[:gist_yarg] = {
784
+ red: ->(x) { 1r - x },
785
+ green: ->(x) { 1r - x },
786
+ blue: ->(x) { 1r - x }
787
+ }
788
+
789
+ # This bipolar colormap was generated from CoolWarmFloat33.csv of
790
+ # "Diverging Color Maps for Scientific Visualization" by Kenneth Moreland.
791
+ # <http://www.kennethmoreland.com/color-maps/>
792
+ data[:coolwarm] = load_colormap_data("coolwarm")
793
+
794
+ # Implementation of Carey Rappaport's CMRmap.
795
+ # See `A Color Map for Effective Black-and-White Rendering of Color-Scale
796
+ # Images' by Carey Rappaport
797
+ # http://www.mathworks.com/matlabcentral/fileexchange/2662-cmrmap-m
798
+ data[:CMRmap] = {
799
+ 'red': [
800
+ [0.000, 0.00, 0.00],
801
+ [0.125, 0.15, 0.15],
802
+ [0.250, 0.30, 0.30],
803
+ [0.375, 0.60, 0.60],
804
+ [0.500, 1.00, 1.00],
805
+ [0.625, 0.90, 0.90],
806
+ [0.750, 0.90, 0.90],
807
+ [0.875, 0.90, 0.90],
808
+ [1.000, 1.00, 1.00]
809
+ ],
810
+ 'green': [
811
+ [0.000, 0.00, 0.00],
812
+ [0.125, 0.15, 0.15],
813
+ [0.250, 0.15, 0.15],
814
+ [0.375, 0.20, 0.20],
815
+ [0.500, 0.25, 0.25],
816
+ [0.625, 0.50, 0.50],
817
+ [0.750, 0.75, 0.75],
818
+ [0.875, 0.90, 0.90],
819
+ [1.000, 1.00, 1.00]
820
+ ],
821
+ 'blue': [
822
+ [0.000, 0.00, 0.00],
823
+ [0.125, 0.50, 0.50],
824
+ [0.250, 0.75, 0.75],
825
+ [0.375, 0.50, 0.50],
826
+ [0.500, 0.15, 0.15],
827
+ [0.625, 0.00, 0.00],
828
+ [0.750, 0.10, 0.10],
829
+ [0.875, 0.50, 0.50],
830
+ [1.000, 1.00, 1.00]
831
+ ]
832
+ }
833
+
834
+ # An MIT licensed, colorblind-friendly heatmap from Wistia:
835
+ # https://github.com/wistia/heatmap-palette
836
+ # http://wistia.com/blog/heatmaps-for-colorblindness
837
+ #
838
+ # >>> import matplotlib.colors as c
839
+ # >>> colors = ["#e4ff7a", "#ffe81a", "#ffbd00", "#ffa000", "#fc7f00"]
840
+ # >>> cm = c.LinearSegmentedColormap.from_list('wistia', colors)
841
+ # >>> _wistia_data = cm._segmentdata
842
+ # >>> del _wistia_data['alpha']
843
+ #
844
+ data[:Wistia] = {
845
+ red: [
846
+ [0.0, 0.8941176470588236, 0.8941176470588236],
847
+ [0.25, 1.0, 1.0],
848
+ [0.5, 1.0, 1.0],
849
+ [0.75, 1.0, 1.0],
850
+ [1.0, 0.9882352941176471, 0.9882352941176471]
851
+ ],
852
+ green: [
853
+ [0.0, 1.0, 1.0],
854
+ [0.25, 0.9098039215686274, 0.9098039215686274],
855
+ [0.5, 0.7411764705882353, 0.7411764705882353],
856
+ [0.75, 0.6274509803921569, 0.6274509803921569],
857
+ [1.0, 0.4980392156862745, 0.4980392156862745]
858
+ ],
859
+ blue: [
860
+ [0.0, 0.47843137254901963, 0.47843137254901963],
861
+ [0.25, 0.10196078431372549, 0.10196078431372549],
862
+ [0.5, 0.0, 0.0],
863
+ [0.75, 0.0, 0.0],
864
+ [1.0, 0.0, 0.0]
865
+ ],
866
+ }
867
+
868
+ # Categorical palettes from Vega:
869
+ # https://github.com/vega/vega/wiki/Scales
870
+ # (divided by 255)
871
+ #
872
+
873
+ data[:tab10] = {listed:[
874
+ [0.12156862745098039, 0.4666666666666667, 0.7058823529411765 ], # 1f77b4
875
+ [1.0, 0.4980392156862745, 0.054901960784313725], # ff7f0e
876
+ [0.17254901960784313, 0.6274509803921569, 0.17254901960784313 ], # 2ca02c
877
+ [0.8392156862745098, 0.15294117647058825, 0.1568627450980392 ], # d62728
878
+ [0.5803921568627451, 0.403921568627451, 0.7411764705882353 ], # 9467bd
879
+ [0.5490196078431373, 0.33725490196078434, 0.29411764705882354 ], # 8c564b
880
+ [0.8901960784313725, 0.4666666666666667, 0.7607843137254902 ], # e377c2
881
+ [0.4980392156862745, 0.4980392156862745, 0.4980392156862745 ], # 7f7f7f
882
+ [0.7372549019607844, 0.7411764705882353, 0.13333333333333333 ], # bcbd22
883
+ [0.09019607843137255, 0.7450980392156863, 0.8117647058823529 ] # 17becf
884
+ ]}
885
+
886
+ data[:tab20] = {listed:[
887
+ [0.12156862745098039, 0.4666666666666667, 0.7058823529411765 ], # 1f77b4
888
+ [0.6823529411764706, 0.7803921568627451, 0.9098039215686274 ], # aec7e8
889
+ [1.0, 0.4980392156862745, 0.054901960784313725], # ff7f0e
890
+ [1.0, 0.7333333333333333, 0.47058823529411764 ], # ffbb78
891
+ [0.17254901960784313, 0.6274509803921569, 0.17254901960784313 ], # 2ca02c
892
+ [0.596078431372549, 0.8745098039215686, 0.5411764705882353 ], # 98df8a
893
+ [0.8392156862745098, 0.15294117647058825, 0.1568627450980392 ], # d62728
894
+ [1.0, 0.596078431372549, 0.5882352941176471 ], # ff9896
895
+ [0.5803921568627451, 0.403921568627451, 0.7411764705882353 ], # 9467bd
896
+ [0.7725490196078432, 0.6901960784313725, 0.8352941176470589 ], # c5b0d5
897
+ [0.5490196078431373, 0.33725490196078434, 0.29411764705882354 ], # 8c564b
898
+ [0.7686274509803922, 0.611764705882353, 0.5803921568627451 ], # c49c94
899
+ [0.8901960784313725, 0.4666666666666667, 0.7607843137254902 ], # e377c2
900
+ [0.9686274509803922, 0.7137254901960784, 0.8235294117647058 ], # f7b6d2
901
+ [0.4980392156862745, 0.4980392156862745, 0.4980392156862745 ], # 7f7f7f
902
+ [0.7803921568627451, 0.7803921568627451, 0.7803921568627451 ], # c7c7c7
903
+ [0.7372549019607844, 0.7411764705882353, 0.13333333333333333 ], # bcbd22
904
+ [0.8588235294117647, 0.8588235294117647, 0.5529411764705883 ], # dbdb8d
905
+ [0.09019607843137255, 0.7450980392156863, 0.8117647058823529 ], # 17becf
906
+ [0.6196078431372549, 0.8549019607843137, 0.8980392156862745 ] # 9edae5
907
+ ]}
908
+
909
+ data[:tab20b] = {listed:[
910
+ [0.2235294117647059, 0.23137254901960785, 0.4745098039215686 ], # 393b79
911
+ [0.3215686274509804, 0.32941176470588235, 0.6392156862745098 ], # 5254a3
912
+ [0.4196078431372549, 0.43137254901960786, 0.8117647058823529 ], # 6b6ecf
913
+ [0.611764705882353, 0.6196078431372549, 0.8705882352941177 ], # 9c9ede
914
+ [0.38823529411764707, 0.4745098039215686, 0.2235294117647059 ], # 637939
915
+ [0.5490196078431373, 0.6352941176470588, 0.3215686274509804 ], # 8ca252
916
+ [0.7098039215686275, 0.8117647058823529, 0.4196078431372549 ], # b5cf6b
917
+ [0.807843137254902, 0.8588235294117647, 0.611764705882353 ], # cedb9c
918
+ [0.5490196078431373, 0.42745098039215684, 0.19215686274509805], # 8c6d31
919
+ [0.7411764705882353, 0.6196078431372549, 0.2235294117647059 ], # bd9e39
920
+ [0.9058823529411765, 0.7294117647058823, 0.3215686274509804 ], # e7ba52
921
+ [0.9058823529411765, 0.796078431372549, 0.5803921568627451 ], # e7cb94
922
+ [0.5176470588235295, 0.23529411764705882, 0.2235294117647059 ], # 843c39
923
+ [0.6784313725490196, 0.28627450980392155, 0.2901960784313726 ], # ad494a
924
+ [0.8392156862745098, 0.3803921568627451, 0.4196078431372549 ], # d6616b
925
+ [0.9058823529411765, 0.5882352941176471, 0.611764705882353 ], # e7969c
926
+ [0.4823529411764706, 0.2549019607843137, 0.45098039215686275], # 7b4173
927
+ [0.6470588235294118, 0.3176470588235294, 0.5803921568627451 ], # a55194
928
+ [0.807843137254902, 0.42745098039215684, 0.7411764705882353 ], # ce6dbd
929
+ [0.8705882352941177, 0.6196078431372549, 0.8392156862745098 ] # de9ed6
930
+ ]}
931
+
932
+ data[:tab20c] = {listed:[
933
+ [0.19215686274509805, 0.5098039215686274, 0.7411764705882353 ], # 3182bd
934
+ [0.4196078431372549, 0.6823529411764706, 0.8392156862745098 ], # 6baed6
935
+ [0.6196078431372549, 0.792156862745098, 0.8823529411764706 ], # 9ecae1
936
+ [0.7764705882352941, 0.8588235294117647, 0.9372549019607843 ], # c6dbef
937
+ [0.9019607843137255, 0.3333333333333333, 0.050980392156862744], # e6550d
938
+ [0.9921568627450981, 0.5529411764705883, 0.23529411764705882 ], # fd8d3c
939
+ [0.9921568627450981, 0.6823529411764706, 0.4196078431372549 ], # fdae6b
940
+ [0.9921568627450981, 0.8156862745098039, 0.6352941176470588 ], # fdd0a2
941
+ [0.19215686274509805, 0.6392156862745098, 0.32941176470588235 ], # 31a354
942
+ [0.4549019607843137, 0.7686274509803922, 0.4627450980392157 ], # 74c476
943
+ [0.6313725490196078, 0.8509803921568627, 0.6078431372549019 ], # a1d99b
944
+ [0.7803921568627451, 0.9137254901960784, 0.7529411764705882 ], # c7e9c0
945
+ [0.4588235294117647, 0.4196078431372549, 0.6941176470588235 ], # 756bb1
946
+ [0.6196078431372549, 0.6039215686274509, 0.7843137254901961 ], # 9e9ac8
947
+ [0.7372549019607844, 0.7411764705882353, 0.8627450980392157 ], # bcbddc
948
+ [0.8549019607843137, 0.8549019607843137, 0.9215686274509803 ], # dadaeb
949
+ [0.38823529411764707, 0.38823529411764707, 0.38823529411764707 ], # 636363
950
+ [0.5882352941176471, 0.5882352941176471, 0.5882352941176471 ], # 969696
951
+ [0.7411764705882353, 0.7411764705882353, 0.7411764705882353 ], # bdbdbd
952
+ [0.8509803921568627, 0.8509803921568627, 0.8509803921568627 ] # d9d9d9
953
+ ]}
954
+
955
+ sorted_names = data.each_key.sort do |a_key, b_key|
956
+ a_data = data[a_key]
957
+ b_data = data[b_key]
958
+ a_listed = a_data.is_a?(Hash) && a_data.key?(:listed)
959
+ b_listed = a_data.is_a?(Hash) && a_data.key?(:listed)
960
+ case
961
+ when !a_listed && b_listed
962
+ -1
963
+ when a_listed && !b_listed
964
+ 1
965
+ else
966
+ a_key <=> b_key
967
+ end
968
+ end
969
+
970
+ sorted_names.each do |name|
971
+ spec = data[name]
972
+ cmap = case
973
+ when spec.is_a?(Hash) && spec.key?(:red)
974
+ LinearSegmentedColormap.new(name.to_s, spec, n_colors: LUT_SIZE)
975
+ when spec.is_a?(Hash) && spec.key?(:listed)
976
+ colors = spec[:listed].map { |rgb| RGB.new(*rgb) }
977
+ ListedColormap.new(colors, name: name.to_s)
978
+ else
979
+ case spec[0][1]
980
+ when Array
981
+ colors = spec.map {|v, rgb| [v, RGB.new(*rgb)] }
982
+ else
983
+ colors = spec.map {|rgb| RGB.new(*rgb) }
984
+ end
985
+ LinearSegmentedColormap.new_from_list(name.to_s, colors, n_colors: LUT_SIZE)
986
+ end
987
+ BUILTIN_COLORMAPS[cmap.name] = cmap
988
+ end
989
+ end
990
+ end