@kidthales/tol-palettes 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. package/LICENSE +36 -0
  2. package/NOTICE +58 -0
  3. package/README.md +182 -2
  4. package/data/schemes/banded-12.json +49 -0
  5. package/data/schemes/banded-16.json +61 -0
  6. package/data/schemes/banded-20.json +73 -0
  7. package/data/schemes/bright.json +48 -0
  8. package/data/schemes/burd.json +43 -0
  9. package/data/schemes/dark.json +45 -0
  10. package/data/schemes/groundcover.json +54 -0
  11. package/data/schemes/high-contrast.json +32 -0
  12. package/data/schemes/incandescent.json +46 -0
  13. package/data/schemes/iridescent.json +85 -0
  14. package/data/schemes/light.json +56 -0
  15. package/data/schemes/medium-contrast.json +44 -0
  16. package/data/schemes/muted.json +61 -0
  17. package/data/schemes/nightfall.json +78 -0
  18. package/data/schemes/pale.json +33 -0
  19. package/data/schemes/prgn.json +43 -0
  20. package/data/schemes/rainbow-discrete.json +430 -0
  21. package/data/schemes/rainbow-smooth.json +143 -0
  22. package/data/schemes/sunset.json +49 -0
  23. package/data/schemes/vibrant.json +48 -0
  24. package/data/schemes/whorbr.json +44 -0
  25. package/data/schemes/ylorbr.json +43 -0
  26. package/dist/aseprite/banded-12.gpl +21 -0
  27. package/dist/aseprite/banded-16.gpl +25 -0
  28. package/dist/aseprite/banded-20.gpl +29 -0
  29. package/dist/aseprite/bright.gpl +17 -0
  30. package/dist/aseprite/burd.gpl +18 -0
  31. package/dist/aseprite/dark.gpl +20 -0
  32. package/dist/aseprite/groundcover.gpl +23 -0
  33. package/dist/aseprite/high-contrast.gpl +13 -0
  34. package/dist/aseprite/incandescent.gpl +20 -0
  35. package/dist/aseprite/iridescent.gpl +32 -0
  36. package/dist/aseprite/light.gpl +19 -0
  37. package/dist/aseprite/medium-contrast.gpl +16 -0
  38. package/dist/aseprite/muted.gpl +20 -0
  39. package/dist/aseprite/nightfall.gpl +26 -0
  40. package/dist/aseprite/pale.gpl +16 -0
  41. package/dist/aseprite/prgn.gpl +18 -0
  42. package/dist/aseprite/rainbow-discrete.gpl +38 -0
  43. package/dist/aseprite/rainbow-smooth.gpl +43 -0
  44. package/dist/aseprite/sunset.gpl +20 -0
  45. package/dist/aseprite/vibrant.gpl +17 -0
  46. package/dist/aseprite/whorbr.gpl +18 -0
  47. package/dist/aseprite/ylorbr.gpl +18 -0
  48. package/dist/css/banded-12.css +23 -0
  49. package/dist/css/banded-16.css +27 -0
  50. package/dist/css/banded-20.css +31 -0
  51. package/dist/css/bright.css +25 -0
  52. package/dist/css/burd.css +21 -0
  53. package/dist/css/dark.css +21 -0
  54. package/dist/css/groundcover.css +24 -0
  55. package/dist/css/high-contrast.css +17 -0
  56. package/dist/css/incandescent.css +23 -0
  57. package/dist/css/iridescent.css +35 -0
  58. package/dist/css/light.css +29 -0
  59. package/dist/css/medium-contrast.css +23 -0
  60. package/dist/css/muted.css +31 -0
  61. package/dist/css/nightfall.css +38 -0
  62. package/dist/css/pale.css +17 -0
  63. package/dist/css/prgn.css +21 -0
  64. package/dist/css/rainbow-discrete.css +316 -0
  65. package/dist/css/rainbow-smooth.css +46 -0
  66. package/dist/css/sunset.css +23 -0
  67. package/dist/css/tol.css +732 -0
  68. package/dist/css/vibrant.css +25 -0
  69. package/dist/css/whorbr.css +21 -0
  70. package/dist/css/ylorbr.css +21 -0
  71. package/dist/godot/addons/tol_palettes/banded-12.tres +10 -0
  72. package/dist/godot/addons/tol_palettes/banded-16.tres +10 -0
  73. package/dist/godot/addons/tol_palettes/banded-20.tres +10 -0
  74. package/dist/godot/addons/tol_palettes/bright.tres +10 -0
  75. package/dist/godot/addons/tol_palettes/burd.tres +10 -0
  76. package/dist/godot/addons/tol_palettes/dark.tres +10 -0
  77. package/dist/godot/addons/tol_palettes/groundcover.tres +10 -0
  78. package/dist/godot/addons/tol_palettes/high-contrast.tres +10 -0
  79. package/dist/godot/addons/tol_palettes/incandescent.tres +10 -0
  80. package/dist/godot/addons/tol_palettes/iridescent.tres +10 -0
  81. package/dist/godot/addons/tol_palettes/light.tres +10 -0
  82. package/dist/godot/addons/tol_palettes/medium-contrast.tres +10 -0
  83. package/dist/godot/addons/tol_palettes/muted.tres +10 -0
  84. package/dist/godot/addons/tol_palettes/nightfall.tres +10 -0
  85. package/dist/godot/addons/tol_palettes/pale.tres +10 -0
  86. package/dist/godot/addons/tol_palettes/plugin.cfg +12 -0
  87. package/dist/godot/addons/tol_palettes/prgn.tres +10 -0
  88. package/dist/godot/addons/tol_palettes/rainbow-discrete.tres +10 -0
  89. package/dist/godot/addons/tol_palettes/rainbow-smooth.tres +10 -0
  90. package/dist/godot/addons/tol_palettes/sunset.tres +10 -0
  91. package/dist/godot/addons/tol_palettes/tol_palettes.gd +301 -0
  92. package/dist/godot/addons/tol_palettes/vibrant.tres +10 -0
  93. package/dist/godot/addons/tol_palettes/whorbr.tres +10 -0
  94. package/dist/godot/addons/tol_palettes/ylorbr.tres +10 -0
  95. package/dist/godot/banded-12.tres +10 -0
  96. package/dist/godot/banded-16.tres +10 -0
  97. package/dist/godot/banded-20.tres +10 -0
  98. package/dist/godot/bright.tres +10 -0
  99. package/dist/godot/burd.tres +10 -0
  100. package/dist/godot/dark.tres +10 -0
  101. package/dist/godot/groundcover.tres +10 -0
  102. package/dist/godot/high-contrast.tres +10 -0
  103. package/dist/godot/incandescent.tres +10 -0
  104. package/dist/godot/iridescent.tres +10 -0
  105. package/dist/godot/light.tres +10 -0
  106. package/dist/godot/medium-contrast.tres +10 -0
  107. package/dist/godot/muted.tres +10 -0
  108. package/dist/godot/nightfall.tres +10 -0
  109. package/dist/godot/pale.tres +10 -0
  110. package/dist/godot/prgn.tres +10 -0
  111. package/dist/godot/rainbow-discrete.tres +10 -0
  112. package/dist/godot/rainbow-smooth.tres +10 -0
  113. package/dist/godot/sunset.tres +10 -0
  114. package/dist/godot/tol_palettes.gd +301 -0
  115. package/dist/godot/vibrant.tres +10 -0
  116. package/dist/godot/whorbr.tres +10 -0
  117. package/dist/godot/ylorbr.tres +10 -0
  118. package/dist/gpl/banded-12.gpl +20 -0
  119. package/dist/gpl/banded-16.gpl +24 -0
  120. package/dist/gpl/banded-20.gpl +28 -0
  121. package/dist/gpl/bright.gpl +16 -0
  122. package/dist/gpl/burd.gpl +17 -0
  123. package/dist/gpl/dark.gpl +19 -0
  124. package/dist/gpl/groundcover.gpl +22 -0
  125. package/dist/gpl/high-contrast.gpl +12 -0
  126. package/dist/gpl/incandescent.gpl +19 -0
  127. package/dist/gpl/iridescent.gpl +31 -0
  128. package/dist/gpl/light.gpl +18 -0
  129. package/dist/gpl/medium-contrast.gpl +15 -0
  130. package/dist/gpl/muted.gpl +19 -0
  131. package/dist/gpl/nightfall.gpl +25 -0
  132. package/dist/gpl/pale.gpl +15 -0
  133. package/dist/gpl/prgn.gpl +17 -0
  134. package/dist/gpl/rainbow-discrete.gpl +37 -0
  135. package/dist/gpl/rainbow-smooth.gpl +42 -0
  136. package/dist/gpl/sunset.gpl +19 -0
  137. package/dist/gpl/vibrant.gpl +16 -0
  138. package/dist/gpl/whorbr.gpl +17 -0
  139. package/dist/gpl/ylorbr.gpl +17 -0
  140. package/dist/js/index.d.ts +92 -0
  141. package/dist/js/index.js +1845 -0
  142. package/dist/json/schemes.json +1613 -0
  143. package/dist/py/tol_palettes.py +1092 -0
  144. package/package.json +82 -4
  145. package/schema/scheme.schema.json +90 -0
@@ -0,0 +1,1092 @@
1
+ """
2
+ Paul Tol colour schemes — generated from data/schemes/*.json by tools/generate-py.mjs.
3
+ Do not edit by hand.
4
+
5
+ Sources:
6
+ - Paul Tol's Notes: https://sronpersonalpages.nl/~pault/
7
+ - Official Python module tol_colors.py (version 2022.10):
8
+ https://sronpersonalpages.nl/~pault/data/tol_colors.py
9
+
10
+ Independent project: not affiliated with or endorsed by Paul Tol.
11
+ Policy: colour values only; colour names are present only where tol_colors.py provides them.
12
+
13
+ 3-Clause BSD Notice for values and colormap structure derived from tol_colors.py:
14
+ Copyright (c) 2022, Paul Tol. All rights reserved.
15
+
16
+ Redistribution and use in source and binary forms, with or without modification,
17
+ are permitted provided that the following conditions are met:
18
+ 1. Redistributions of source code must retain the above copyright notice, this
19
+ list of conditions and the following disclaimer.
20
+ 2. Redistributions in binary form must reproduce the above copyright notice,
21
+ this list of conditions and the following disclaimer in the documentation
22
+ and/or other materials provided with the distribution.
23
+ 3. Neither the name of the copyright holder nor the names of its contributors
24
+ may be used to endorse or promote products derived from this software without
25
+ specific prior written permission.
26
+
27
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
28
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
29
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
30
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
31
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
32
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
33
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
34
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37
+ """
38
+
39
+ from collections import namedtuple
40
+
41
+ __all__ = [
42
+ 'SCHEMES',
43
+ 'OFFICIAL_CSET_NAMES',
44
+ 'CSET_NAMES',
45
+ 'OFFICIAL_CMAP_NAMES',
46
+ 'CMAP_NAMES',
47
+ 'tol_cset',
48
+ 'tol_cmap_colors',
49
+ 'tol_cmap',
50
+ 'discretemap',
51
+ ]
52
+
53
+ SCHEMES = {
54
+ 'banded-12': {
55
+ 'id': 'banded-12',
56
+ 'kind': 'sequential',
57
+ 'colors': ('#D2D1E2', '#C1A7C4', '#AD7BA4', '#93C7EC', '#6DA1D6', '#3E79BD', '#B8D29E', '#7BB47D', '#2C925B', '#F4A937', '#EB7121', '#D9070D'),
58
+ 'bad': '#FFFFFF',
59
+ 'interpolation': 'none',
60
+ },
61
+ 'banded-16': {
62
+ 'id': 'banded-16',
63
+ 'kind': 'sequential',
64
+ 'colors': (
65
+ '#D2D1E2',
66
+ '#C5B3CC',
67
+ '#B893B5',
68
+ '#A8719D',
69
+ '#97CDEF',
70
+ '#7DB1DF',
71
+ '#5F94CE',
72
+ '#3976BB',
73
+ '#BCD4A0',
74
+ '#90BE88',
75
+ '#60A770',
76
+ '#198D56',
77
+ '#F5B43B',
78
+ '#F08C2B',
79
+ '#E85E1B',
80
+ '#D9070D',
81
+ ),
82
+ 'bad': '#FFFFFF',
83
+ 'interpolation': 'none',
84
+ },
85
+ 'banded-20': {
86
+ 'id': 'banded-20',
87
+ 'kind': 'sequential',
88
+ 'colors': (
89
+ '#D2D1E2',
90
+ '#C8B9D1',
91
+ '#BEA0BF',
92
+ '#B287AD',
93
+ '#A56B99',
94
+ '#9ACFF1',
95
+ '#85BAE4',
96
+ '#6FA3D7',
97
+ '#578DC9',
98
+ '#3774BA',
99
+ '#BFD6A1',
100
+ '#9CC48E',
101
+ '#78B27B',
102
+ '#4F9F68',
103
+ '#058A53',
104
+ '#F6B93D',
105
+ '#F29B31',
106
+ '#ED7A24',
107
+ '#E65318',
108
+ '#D9070D',
109
+ ),
110
+ 'bad': '#FFFFFF',
111
+ 'interpolation': 'none',
112
+ },
113
+ 'bright': {
114
+ 'id': 'bright',
115
+ 'kind': 'qualitative',
116
+ 'colors': ('#4477AA', '#EE6677', '#228833', '#CCBB44', '#66CCEE', '#AA3377', '#BBBBBB'),
117
+ 'extras': ('#000000',),
118
+ 'interpolation': 'none',
119
+ },
120
+ 'burd': {
121
+ 'id': 'burd',
122
+ 'kind': 'diverging',
123
+ 'colors': ('#2166AC', '#4393C3', '#92C5DE', '#D1E5F0', '#F7F7F7', '#FDDBC7', '#F4A582', '#D6604D', '#B2182B'),
124
+ 'bad': '#FFEE99',
125
+ 'interpolation': 'either',
126
+ },
127
+ 'dark': {
128
+ 'id': 'dark',
129
+ 'kind': 'qualitative',
130
+ 'colors': ('#4477BB', '#CC4466', '#228833', '#2255AA', '#993366', '#006644', '#117788', '#882288', '#BB4488', '#775500', '#444444'),
131
+ 'interpolation': 'none',
132
+ },
133
+ 'groundcover': {
134
+ 'id': 'groundcover',
135
+ 'kind': 'special',
136
+ 'colors': (
137
+ '#5566AA',
138
+ '#117733',
139
+ '#44AA66',
140
+ '#55AA22',
141
+ '#668822',
142
+ '#99BB55',
143
+ '#558877',
144
+ '#88BBAA',
145
+ '#AADDCC',
146
+ '#44AA88',
147
+ '#DDCC66',
148
+ '#FFDD44',
149
+ '#FFEE88',
150
+ '#BB0011',
151
+ ),
152
+ 'interpolation': 'none',
153
+ },
154
+ 'high-contrast': {
155
+ 'id': 'high-contrast',
156
+ 'kind': 'qualitative',
157
+ 'colors': ('#004488', '#DDAA33', '#BB5566'),
158
+ 'extras': ('#000000',),
159
+ 'interpolation': 'none',
160
+ },
161
+ 'incandescent': {
162
+ 'id': 'incandescent',
163
+ 'kind': 'sequential',
164
+ 'colors': ('#CEFFFF', '#C6F7D6', '#A2F49B', '#BBE453', '#D5CE04', '#E7B503', '#F19903', '#F6790B', '#F94902', '#E40515', '#A80003'),
165
+ 'bad': '#888888',
166
+ 'interpolation': 'linear',
167
+ },
168
+ 'iridescent': {
169
+ 'id': 'iridescent',
170
+ 'kind': 'sequential',
171
+ 'colors': (
172
+ '#FEFBE9',
173
+ '#FCF7D5',
174
+ '#F5F3C1',
175
+ '#EAF0B5',
176
+ '#DDECBF',
177
+ '#D0E7CA',
178
+ '#C2E3D2',
179
+ '#B5DDD8',
180
+ '#A8D8DC',
181
+ '#9BD2E1',
182
+ '#8DCBE4',
183
+ '#81C4E7',
184
+ '#7BBCE7',
185
+ '#7EB2E4',
186
+ '#88A5DD',
187
+ '#9398D2',
188
+ '#9B8AC4',
189
+ '#9D7DB2',
190
+ '#9A709E',
191
+ '#906388',
192
+ '#805770',
193
+ '#684957',
194
+ '#46353A',
195
+ ),
196
+ 'bad': '#999999',
197
+ 'interpolation': 'linear',
198
+ },
199
+ 'light': {
200
+ 'id': 'light',
201
+ 'kind': 'qualitative',
202
+ 'colors': ('#77AADD', '#EE8866', '#EEDD88', '#FFAABB', '#99DDFF', '#44BB99', '#BBCC33', '#AAAA00', '#DDDDDD'),
203
+ 'extras': ('#000000',),
204
+ 'interpolation': 'none',
205
+ },
206
+ 'medium-contrast': {
207
+ 'id': 'medium-contrast',
208
+ 'kind': 'qualitative',
209
+ 'colors': ('#6699CC', '#004488', '#EECC66', '#994455', '#997700', '#EE99AA'),
210
+ 'extras': ('#000000',),
211
+ 'interpolation': 'none',
212
+ },
213
+ 'muted': {
214
+ 'id': 'muted',
215
+ 'kind': 'qualitative',
216
+ 'colors': ('#CC6677', '#332288', '#DDCC77', '#117733', '#88CCEE', '#882255', '#44AA99', '#999933', '#AA4499'),
217
+ 'extras': ('#DDDDDD', '#000000'),
218
+ 'bad': '#DDDDDD',
219
+ 'interpolation': 'none',
220
+ },
221
+ 'nightfall': {
222
+ 'id': 'nightfall',
223
+ 'kind': 'diverging',
224
+ 'colors': (
225
+ '#125A56',
226
+ '#00767B',
227
+ '#238F9D',
228
+ '#42A7C6',
229
+ '#60BCE9',
230
+ '#9DCCEF',
231
+ '#C6DBED',
232
+ '#DEE6E7',
233
+ '#ECEADA',
234
+ '#F0E6B2',
235
+ '#F9D576',
236
+ '#FFB954',
237
+ '#FD9A44',
238
+ '#F57634',
239
+ '#E94C1F',
240
+ '#D11807',
241
+ '#A01813',
242
+ ),
243
+ 'bad': '#FFFFFF',
244
+ 'interpolation': 'either',
245
+ },
246
+ 'pale': {
247
+ 'id': 'pale',
248
+ 'kind': 'qualitative',
249
+ 'colors': ('#AACCEE', '#CCEEFF', '#BBDDBB', '#EEEEBB', '#FFBBCC', '#EEBBDD', '#DDDDDD'),
250
+ 'interpolation': 'none',
251
+ },
252
+ 'prgn': {
253
+ 'id': 'prgn',
254
+ 'kind': 'diverging',
255
+ 'colors': ('#762A83', '#9970AB', '#C2A5CF', '#E7D4E8', '#F7F7F7', '#D9F0D3', '#ACD39E', '#5AAE61', '#1B7837'),
256
+ 'bad': '#FFEE99',
257
+ 'interpolation': 'either',
258
+ },
259
+ 'rainbow-discrete': {
260
+ 'id': 'rainbow-discrete',
261
+ 'kind': 'sequential',
262
+ 'colors': (
263
+ '#E8ECFB',
264
+ '#D9CCE3',
265
+ '#D1BBD7',
266
+ '#CAACCB',
267
+ '#BA8DB4',
268
+ '#AE76A3',
269
+ '#AA6F9E',
270
+ '#994F88',
271
+ '#882E72',
272
+ '#1965B0',
273
+ '#437DBF',
274
+ '#5289C7',
275
+ '#6195CF',
276
+ '#7BAFDE',
277
+ '#4EB265',
278
+ '#90C987',
279
+ '#CAE0AB',
280
+ '#F7F056',
281
+ '#F7CB45',
282
+ '#F6C141',
283
+ '#F4A736',
284
+ '#F1932D',
285
+ '#EE8026',
286
+ '#E8601C',
287
+ '#E65518',
288
+ '#DC050C',
289
+ '#A5170E',
290
+ '#72190E',
291
+ '#42150A',
292
+ ),
293
+ 'bad': '#FFFFFF',
294
+ 'interpolation': 'none',
295
+ },
296
+ 'rainbow-smooth': {
297
+ 'id': 'rainbow-smooth',
298
+ 'kind': 'sequential',
299
+ 'colors': (
300
+ '#E8ECFB',
301
+ '#DDD8EF',
302
+ '#D1C1E1',
303
+ '#C3A8D1',
304
+ '#B58FC2',
305
+ '#A778B4',
306
+ '#9B62A7',
307
+ '#8C4E99',
308
+ '#6F4C9B',
309
+ '#6059A9',
310
+ '#5568B8',
311
+ '#4E79C5',
312
+ '#4D8AC6',
313
+ '#4E96BC',
314
+ '#549EB3',
315
+ '#59A5A9',
316
+ '#60AB9E',
317
+ '#69B190',
318
+ '#77B77D',
319
+ '#8CBC68',
320
+ '#A6BE54',
321
+ '#BEBC48',
322
+ '#D1B541',
323
+ '#DDAA3C',
324
+ '#E49C39',
325
+ '#E78C35',
326
+ '#E67932',
327
+ '#E4632D',
328
+ '#DF4828',
329
+ '#DA2222',
330
+ '#B8221E',
331
+ '#95211B',
332
+ '#721E17',
333
+ '#521A13',
334
+ ),
335
+ 'bad': '#666666',
336
+ 'interpolation': 'linear',
337
+ },
338
+ 'sunset': {
339
+ 'id': 'sunset',
340
+ 'kind': 'diverging',
341
+ 'colors': ('#364B9A', '#4A7BB7', '#6EA6CD', '#98CAE1', '#C2E4EF', '#EAECCC', '#FEDA8B', '#FDB366', '#F67E4B', '#DD3D2D', '#A50026'),
342
+ 'bad': '#FFFFFF',
343
+ 'interpolation': 'either',
344
+ },
345
+ 'vibrant': {
346
+ 'id': 'vibrant',
347
+ 'kind': 'qualitative',
348
+ 'colors': ('#EE7733', '#0077BB', '#33BBEE', '#EE3377', '#CC3311', '#009988', '#BBBBBB'),
349
+ 'extras': ('#000000',),
350
+ 'interpolation': 'none',
351
+ },
352
+ 'whorbr': {
353
+ 'id': 'whorbr',
354
+ 'kind': 'sequential',
355
+ 'colors': ('#FFFFFF', '#FFF7BC', '#FEE391', '#FEC44F', '#FB9A29', '#EC7014', '#CC4C02', '#993404', '#662506'),
356
+ 'bad': '#888888',
357
+ 'interpolation': 'linear',
358
+ },
359
+ 'ylorbr': {
360
+ 'id': 'ylorbr',
361
+ 'kind': 'sequential',
362
+ 'colors': ('#FFFFE5', '#FFF7BC', '#FEE391', '#FEC44F', '#FB9A29', '#EC7014', '#CC4C02', '#993404', '#662506'),
363
+ 'bad': '#888888',
364
+ 'interpolation': 'either',
365
+ },
366
+ }
367
+
368
+ OFFICIAL_CSET_NAMES = ('bright', 'high-contrast', 'vibrant', 'muted', 'medium-contrast', 'light')
369
+
370
+ CSET_NAMES = ('bright', 'high-contrast', 'vibrant', 'muted', 'medium-contrast', 'light', 'dark', 'pale', 'groundcover')
371
+
372
+ _NAMED_CSETS = {
373
+ 'bright': {
374
+ 'fields': ('blue', 'red', 'green', 'yellow', 'cyan', 'purple', 'grey', 'black'),
375
+ 'hex': ('#4477AA', '#EE6677', '#228833', '#CCBB44', '#66CCEE', '#AA3377', '#BBBBBB', '#000000'),
376
+ },
377
+ 'high-contrast': {
378
+ 'fields': ('blue', 'yellow', 'red', 'black'),
379
+ 'hex': ('#004488', '#DDAA33', '#BB5566', '#000000'),
380
+ },
381
+ 'vibrant': {
382
+ 'fields': ('orange', 'blue', 'cyan', 'magenta', 'red', 'teal', 'grey', 'black'),
383
+ 'hex': ('#EE7733', '#0077BB', '#33BBEE', '#EE3377', '#CC3311', '#009988', '#BBBBBB', '#000000'),
384
+ },
385
+ 'muted': {
386
+ 'fields': ('rose', 'indigo', 'sand', 'green', 'cyan', 'wine', 'teal', 'olive', 'purple', 'pale_grey', 'black'),
387
+ 'hex': ('#CC6677', '#332288', '#DDCC77', '#117733', '#88CCEE', '#882255', '#44AA99', '#999933', '#AA4499', '#DDDDDD', '#000000'),
388
+ },
389
+ 'medium-contrast': {
390
+ 'fields': ('light_blue', 'dark_blue', 'light_yellow', 'dark_red', 'dark_yellow', 'light_red', 'black'),
391
+ 'hex': ('#6699CC', '#004488', '#EECC66', '#994455', '#997700', '#EE99AA', '#000000'),
392
+ },
393
+ 'light': {
394
+ 'fields': ('light_blue', 'orange', 'light_yellow', 'pink', 'light_cyan', 'mint', 'pear', 'olive', 'pale_grey', 'black'),
395
+ 'hex': ('#77AADD', '#EE8866', '#EEDD88', '#FFAABB', '#99DDFF', '#44BB99', '#BBCC33', '#AAAA00', '#DDDDDD', '#000000'),
396
+ },
397
+ }
398
+
399
+ _UNNAMED_CSETS = {
400
+ 'dark': ('#4477BB', '#CC4466', '#228833', '#2255AA', '#993366', '#006644', '#117788', '#882288', '#BB4488', '#775500', '#444444'),
401
+ 'pale': ('#AACCEE', '#CCEEFF', '#BBDDBB', '#EEEEBB', '#FFBBCC', '#EEBBDD', '#DDDDDD'),
402
+ 'groundcover': (
403
+ '#5566AA',
404
+ '#117733',
405
+ '#44AA66',
406
+ '#55AA22',
407
+ '#668822',
408
+ '#99BB55',
409
+ '#558877',
410
+ '#88BBAA',
411
+ '#AADDCC',
412
+ '#44AA88',
413
+ '#DDCC66',
414
+ '#FFDD44',
415
+ '#FFEE88',
416
+ '#BB0011',
417
+ ),
418
+ }
419
+
420
+ OFFICIAL_CMAP_NAMES = (
421
+ 'sunset_discrete', 'sunset', 'nightfall_discrete', 'nightfall',
422
+ 'BuRd_discrete', 'BuRd', 'PRGn_discrete', 'PRGn',
423
+ 'YlOrBr_discrete', 'YlOrBr', 'WhOrBr', 'iridescent',
424
+ 'rainbow_PuRd', 'rainbow_PuBr', 'rainbow_WhRd', 'rainbow_WhBr',
425
+ 'rainbow_discrete',
426
+ )
427
+
428
+ _CMAPS = {
429
+ 'sunset_discrete': {
430
+ 'colors': ('#364B9A', '#4A7BB7', '#6EA6CD', '#98CAE1', '#C2E4EF', '#EAECCC', '#FEDA8B', '#FDB366', '#F67E4B', '#DD3D2D', '#A50026'),
431
+ 'bad': '#FFFFFF',
432
+ 'mode': 'discrete',
433
+ },
434
+ 'sunset': {
435
+ 'colors': ('#364B9A', '#4A7BB7', '#6EA6CD', '#98CAE1', '#C2E4EF', '#EAECCC', '#FEDA8B', '#FDB366', '#F67E4B', '#DD3D2D', '#A50026'),
436
+ 'bad': '#FFFFFF',
437
+ 'mode': 'linear',
438
+ },
439
+ 'nightfall_discrete': {
440
+ 'colors': ('#125A56', '#238F9D', '#60BCE9', '#C6DBED', '#ECEADA', '#F9D576', '#FD9A44', '#E94C1F', '#A01813'),
441
+ 'bad': '#FFFFFF',
442
+ 'mode': 'discrete',
443
+ },
444
+ 'nightfall': {
445
+ 'colors': (
446
+ '#125A56',
447
+ '#00767B',
448
+ '#238F9D',
449
+ '#42A7C6',
450
+ '#60BCE9',
451
+ '#9DCCEF',
452
+ '#C6DBED',
453
+ '#DEE6E7',
454
+ '#ECEADA',
455
+ '#F0E6B2',
456
+ '#F9D576',
457
+ '#FFB954',
458
+ '#FD9A44',
459
+ '#F57634',
460
+ '#E94C1F',
461
+ '#D11807',
462
+ '#A01813',
463
+ ),
464
+ 'bad': '#FFFFFF',
465
+ 'mode': 'linear',
466
+ },
467
+ 'BuRd_discrete': {
468
+ 'colors': ('#2166AC', '#4393C3', '#92C5DE', '#D1E5F0', '#F7F7F7', '#FDDBC7', '#F4A582', '#D6604D', '#B2182B'),
469
+ 'bad': '#FFEE99',
470
+ 'mode': 'discrete',
471
+ },
472
+ 'BuRd': {
473
+ 'colors': ('#2166AC', '#4393C3', '#92C5DE', '#D1E5F0', '#F7F7F7', '#FDDBC7', '#F4A582', '#D6604D', '#B2182B'),
474
+ 'bad': '#FFEE99',
475
+ 'mode': 'linear',
476
+ },
477
+ 'PRGn_discrete': {
478
+ 'colors': ('#762A83', '#9970AB', '#C2A5CF', '#E7D4E8', '#F7F7F7', '#D9F0D3', '#ACD39E', '#5AAE61', '#1B7837'),
479
+ 'bad': '#FFEE99',
480
+ 'mode': 'discrete',
481
+ },
482
+ 'PRGn': {
483
+ 'colors': ('#762A83', '#9970AB', '#C2A5CF', '#E7D4E8', '#F7F7F7', '#D9F0D3', '#ACD39E', '#5AAE61', '#1B7837'),
484
+ 'bad': '#FFEE99',
485
+ 'mode': 'linear',
486
+ },
487
+ 'YlOrBr_discrete': {
488
+ 'colors': ('#FFFFE5', '#FFF7BC', '#FEE391', '#FEC44F', '#FB9A29', '#EC7014', '#CC4C02', '#993404', '#662506'),
489
+ 'bad': '#888888',
490
+ 'mode': 'discrete',
491
+ },
492
+ 'YlOrBr': {
493
+ 'colors': ('#FFFFE5', '#FFF7BC', '#FEE391', '#FEC44F', '#FB9A29', '#EC7014', '#CC4C02', '#993404', '#662506'),
494
+ 'bad': '#888888',
495
+ 'mode': 'linear',
496
+ },
497
+ 'WhOrBr': {
498
+ 'colors': ('#FFFFFF', '#FFF7BC', '#FEE391', '#FEC44F', '#FB9A29', '#EC7014', '#CC4C02', '#993404', '#662506'),
499
+ 'bad': '#888888',
500
+ 'mode': 'linear',
501
+ },
502
+ 'iridescent': {
503
+ 'colors': (
504
+ '#FEFBE9',
505
+ '#FCF7D5',
506
+ '#F5F3C1',
507
+ '#EAF0B5',
508
+ '#DDECBF',
509
+ '#D0E7CA',
510
+ '#C2E3D2',
511
+ '#B5DDD8',
512
+ '#A8D8DC',
513
+ '#9BD2E1',
514
+ '#8DCBE4',
515
+ '#81C4E7',
516
+ '#7BBCE7',
517
+ '#7EB2E4',
518
+ '#88A5DD',
519
+ '#9398D2',
520
+ '#9B8AC4',
521
+ '#9D7DB2',
522
+ '#9A709E',
523
+ '#906388',
524
+ '#805770',
525
+ '#684957',
526
+ '#46353A',
527
+ ),
528
+ 'bad': '#999999',
529
+ 'mode': 'linear',
530
+ },
531
+ 'rainbow_WhRd': {
532
+ 'colors': (
533
+ '#E8ECFB',
534
+ '#DDD8EF',
535
+ '#D1C1E1',
536
+ '#C3A8D1',
537
+ '#B58FC2',
538
+ '#A778B4',
539
+ '#9B62A7',
540
+ '#8C4E99',
541
+ '#6F4C9B',
542
+ '#6059A9',
543
+ '#5568B8',
544
+ '#4E79C5',
545
+ '#4D8AC6',
546
+ '#4E96BC',
547
+ '#549EB3',
548
+ '#59A5A9',
549
+ '#60AB9E',
550
+ '#69B190',
551
+ '#77B77D',
552
+ '#8CBC68',
553
+ '#A6BE54',
554
+ '#BEBC48',
555
+ '#D1B541',
556
+ '#DDAA3C',
557
+ '#E49C39',
558
+ '#E78C35',
559
+ '#E67932',
560
+ '#E4632D',
561
+ '#DF4828',
562
+ '#DA2222',
563
+ ),
564
+ 'bad': '#666666',
565
+ 'mode': 'linear',
566
+ },
567
+ 'rainbow_WhBr': {
568
+ 'colors': (
569
+ '#E8ECFB',
570
+ '#DDD8EF',
571
+ '#D1C1E1',
572
+ '#C3A8D1',
573
+ '#B58FC2',
574
+ '#A778B4',
575
+ '#9B62A7',
576
+ '#8C4E99',
577
+ '#6F4C9B',
578
+ '#6059A9',
579
+ '#5568B8',
580
+ '#4E79C5',
581
+ '#4D8AC6',
582
+ '#4E96BC',
583
+ '#549EB3',
584
+ '#59A5A9',
585
+ '#60AB9E',
586
+ '#69B190',
587
+ '#77B77D',
588
+ '#8CBC68',
589
+ '#A6BE54',
590
+ '#BEBC48',
591
+ '#D1B541',
592
+ '#DDAA3C',
593
+ '#E49C39',
594
+ '#E78C35',
595
+ '#E67932',
596
+ '#E4632D',
597
+ '#DF4828',
598
+ '#DA2222',
599
+ '#B8221E',
600
+ '#95211B',
601
+ '#721E17',
602
+ '#521A13',
603
+ ),
604
+ 'bad': '#666666',
605
+ 'mode': 'linear',
606
+ },
607
+ 'rainbow_PuRd': {
608
+ 'colors': (
609
+ '#6F4C9B',
610
+ '#6059A9',
611
+ '#5568B8',
612
+ '#4E79C5',
613
+ '#4D8AC6',
614
+ '#4E96BC',
615
+ '#549EB3',
616
+ '#59A5A9',
617
+ '#60AB9E',
618
+ '#69B190',
619
+ '#77B77D',
620
+ '#8CBC68',
621
+ '#A6BE54',
622
+ '#BEBC48',
623
+ '#D1B541',
624
+ '#DDAA3C',
625
+ '#E49C39',
626
+ '#E78C35',
627
+ '#E67932',
628
+ '#E4632D',
629
+ '#DF4828',
630
+ '#DA2222',
631
+ ),
632
+ 'bad': '#FFFFFF',
633
+ 'mode': 'linear',
634
+ },
635
+ 'rainbow_PuBr': {
636
+ 'colors': (
637
+ '#6F4C9B',
638
+ '#6059A9',
639
+ '#5568B8',
640
+ '#4E79C5',
641
+ '#4D8AC6',
642
+ '#4E96BC',
643
+ '#549EB3',
644
+ '#59A5A9',
645
+ '#60AB9E',
646
+ '#69B190',
647
+ '#77B77D',
648
+ '#8CBC68',
649
+ '#A6BE54',
650
+ '#BEBC48',
651
+ '#D1B541',
652
+ '#DDAA3C',
653
+ '#E49C39',
654
+ '#E78C35',
655
+ '#E67932',
656
+ '#E4632D',
657
+ '#DF4828',
658
+ '#DA2222',
659
+ '#B8221E',
660
+ '#95211B',
661
+ '#721E17',
662
+ '#521A13',
663
+ ),
664
+ 'bad': '#FFFFFF',
665
+ 'mode': 'linear',
666
+ },
667
+ 'incandescent': {
668
+ 'colors': ('#CEFFFF', '#C6F7D6', '#A2F49B', '#BBE453', '#D5CE04', '#E7B503', '#F19903', '#F6790B', '#F94902', '#E40515', '#A80003'),
669
+ 'bad': '#888888',
670
+ 'mode': 'linear',
671
+ },
672
+ 'incandescent_discrete': {
673
+ 'colors': ('#CEFFFF', '#C6F7D6', '#A2F49B', '#BBE453', '#D5CE04', '#E7B503', '#F19903', '#F6790B', '#F94902', '#E40515', '#A80003'),
674
+ 'bad': '#888888',
675
+ 'mode': 'discrete',
676
+ },
677
+ 'banded_12': {
678
+ 'colors': ('#D2D1E2', '#C1A7C4', '#AD7BA4', '#93C7EC', '#6DA1D6', '#3E79BD', '#B8D29E', '#7BB47D', '#2C925B', '#F4A937', '#EB7121', '#D9070D'),
679
+ 'bad': '#FFFFFF',
680
+ 'mode': 'discrete',
681
+ },
682
+ 'banded_16': {
683
+ 'colors': (
684
+ '#D2D1E2',
685
+ '#C5B3CC',
686
+ '#B893B5',
687
+ '#A8719D',
688
+ '#97CDEF',
689
+ '#7DB1DF',
690
+ '#5F94CE',
691
+ '#3976BB',
692
+ '#BCD4A0',
693
+ '#90BE88',
694
+ '#60A770',
695
+ '#198D56',
696
+ '#F5B43B',
697
+ '#F08C2B',
698
+ '#E85E1B',
699
+ '#D9070D',
700
+ ),
701
+ 'bad': '#FFFFFF',
702
+ 'mode': 'discrete',
703
+ },
704
+ 'banded_20': {
705
+ 'colors': (
706
+ '#D2D1E2',
707
+ '#C8B9D1',
708
+ '#BEA0BF',
709
+ '#B287AD',
710
+ '#A56B99',
711
+ '#9ACFF1',
712
+ '#85BAE4',
713
+ '#6FA3D7',
714
+ '#578DC9',
715
+ '#3774BA',
716
+ '#BFD6A1',
717
+ '#9CC48E',
718
+ '#78B27B',
719
+ '#4F9F68',
720
+ '#058A53',
721
+ '#F6B93D',
722
+ '#F29B31',
723
+ '#ED7A24',
724
+ '#E65318',
725
+ '#D9070D',
726
+ ),
727
+ 'bad': '#FFFFFF',
728
+ 'mode': 'discrete',
729
+ },
730
+ }
731
+
732
+ _RAINBOW_DISCRETE_COLORS = (
733
+ '#E8ECFB',
734
+ '#D9CCE3',
735
+ '#D1BBD7',
736
+ '#CAACCB',
737
+ '#BA8DB4',
738
+ '#AE76A3',
739
+ '#AA6F9E',
740
+ '#994F88',
741
+ '#882E72',
742
+ '#1965B0',
743
+ '#437DBF',
744
+ '#5289C7',
745
+ '#6195CF',
746
+ '#7BAFDE',
747
+ '#4EB265',
748
+ '#90C987',
749
+ '#CAE0AB',
750
+ '#F7F056',
751
+ '#F7CB45',
752
+ '#F6C141',
753
+ '#F4A736',
754
+ '#F1932D',
755
+ '#EE8026',
756
+ '#E8601C',
757
+ '#E65518',
758
+ '#DC050C',
759
+ '#A5170E',
760
+ '#72190E',
761
+ '#42150A',
762
+ )
763
+
764
+ _RAINBOW_DISCRETE_LUT = (
765
+ (9,),
766
+ (9, 25),
767
+ (9, 17, 25),
768
+ (9, 14, 17, 25),
769
+ (9, 13, 14, 17, 25),
770
+ (9, 13, 14, 16, 17, 25),
771
+ (8, 9, 13, 14, 16, 17, 25),
772
+ (8, 9, 13, 14, 16, 17, 22, 25),
773
+ (8, 9, 13, 14, 16, 17, 22, 25, 27),
774
+ (8, 9, 13, 14, 16, 17, 20, 23, 25, 27),
775
+ (8, 9, 11, 13, 14, 16, 17, 20, 23, 25, 27),
776
+ (2, 5, 8, 9, 11, 13, 14, 16, 17, 20, 23, 25),
777
+ (
778
+ 2,
779
+ 5,
780
+ 8,
781
+ 9,
782
+ 11,
783
+ 13,
784
+ 14,
785
+ 15,
786
+ 16,
787
+ 17,
788
+ 20,
789
+ 23,
790
+ 25,
791
+ ),
792
+ (
793
+ 2,
794
+ 5,
795
+ 8,
796
+ 9,
797
+ 11,
798
+ 13,
799
+ 14,
800
+ 15,
801
+ 16,
802
+ 17,
803
+ 19,
804
+ 21,
805
+ 23,
806
+ 25,
807
+ ),
808
+ (
809
+ 2,
810
+ 5,
811
+ 8,
812
+ 9,
813
+ 11,
814
+ 13,
815
+ 14,
816
+ 15,
817
+ 16,
818
+ 17,
819
+ 19,
820
+ 21,
821
+ 23,
822
+ 25,
823
+ 27,
824
+ ),
825
+ (
826
+ 2,
827
+ 4,
828
+ 6,
829
+ 8,
830
+ 9,
831
+ 11,
832
+ 13,
833
+ 14,
834
+ 15,
835
+ 16,
836
+ 17,
837
+ 19,
838
+ 21,
839
+ 23,
840
+ 25,
841
+ 27,
842
+ ),
843
+ (
844
+ 2,
845
+ 4,
846
+ 6,
847
+ 7,
848
+ 8,
849
+ 9,
850
+ 11,
851
+ 13,
852
+ 14,
853
+ 15,
854
+ 16,
855
+ 17,
856
+ 19,
857
+ 21,
858
+ 23,
859
+ 25,
860
+ 27,
861
+ ),
862
+ (
863
+ 2,
864
+ 4,
865
+ 6,
866
+ 7,
867
+ 8,
868
+ 9,
869
+ 11,
870
+ 13,
871
+ 14,
872
+ 15,
873
+ 16,
874
+ 17,
875
+ 19,
876
+ 21,
877
+ 23,
878
+ 25,
879
+ 26,
880
+ 27,
881
+ ),
882
+ (
883
+ 1,
884
+ 3,
885
+ 4,
886
+ 6,
887
+ 7,
888
+ 8,
889
+ 9,
890
+ 11,
891
+ 13,
892
+ 14,
893
+ 15,
894
+ 16,
895
+ 17,
896
+ 19,
897
+ 21,
898
+ 23,
899
+ 25,
900
+ 26,
901
+ 27,
902
+ ),
903
+ (
904
+ 1,
905
+ 3,
906
+ 4,
907
+ 6,
908
+ 7,
909
+ 8,
910
+ 9,
911
+ 10,
912
+ 12,
913
+ 13,
914
+ 14,
915
+ 15,
916
+ 16,
917
+ 17,
918
+ 19,
919
+ 21,
920
+ 23,
921
+ 25,
922
+ 26,
923
+ 27,
924
+ ),
925
+ (
926
+ 1,
927
+ 3,
928
+ 4,
929
+ 6,
930
+ 7,
931
+ 8,
932
+ 9,
933
+ 10,
934
+ 12,
935
+ 13,
936
+ 14,
937
+ 15,
938
+ 16,
939
+ 17,
940
+ 18,
941
+ 20,
942
+ 22,
943
+ 24,
944
+ 25,
945
+ 26,
946
+ 27,
947
+ ),
948
+ (
949
+ 1,
950
+ 3,
951
+ 4,
952
+ 6,
953
+ 7,
954
+ 8,
955
+ 9,
956
+ 10,
957
+ 12,
958
+ 13,
959
+ 14,
960
+ 15,
961
+ 16,
962
+ 17,
963
+ 18,
964
+ 20,
965
+ 22,
966
+ 24,
967
+ 25,
968
+ 26,
969
+ 27,
970
+ 28,
971
+ ),
972
+ (
973
+ 0,
974
+ 1,
975
+ 3,
976
+ 4,
977
+ 6,
978
+ 7,
979
+ 8,
980
+ 9,
981
+ 10,
982
+ 12,
983
+ 13,
984
+ 14,
985
+ 15,
986
+ 16,
987
+ 17,
988
+ 18,
989
+ 20,
990
+ 22,
991
+ 24,
992
+ 25,
993
+ 26,
994
+ 27,
995
+ 28,
996
+ ),
997
+ )
998
+
999
+ _RAINBOW_DISCRETE_BAD = {
1000
+ '23': '#777777',
1001
+ }
1002
+
1003
+ _RAINBOW_DISCRETE_DEFAULT_BAD = '#FFFFFF'
1004
+
1005
+ CMAP_NAMES = OFFICIAL_CMAP_NAMES + (
1006
+ 'incandescent', 'incandescent_discrete',
1007
+ 'banded_12', 'banded_16', 'banded_20',
1008
+ )
1009
+
1010
+
1011
+ def tol_cset(colorset=None):
1012
+ """
1013
+ Discrete colour sets for qualitative and categorical data.
1014
+
1015
+ - When 'colorset' is None, returns 'OFFICIAL_CSET_NAMES'.
1016
+ - For schemes from tol_colors.py ('bright', 'high-contrast', 'vibrant',
1017
+ 'muted', 'medium-contrast', 'light'), returns a namedtuple with the
1018
+ official colour names and hex values.
1019
+ - For site-only schemes ('dark', 'pale', 'groundcover'), returns a tuple
1020
+ of #RRGGBB hex strings (no colour names are invented).
1021
+ """
1022
+ if colorset is None:
1023
+ return OFFICIAL_CSET_NAMES
1024
+ if colorset in _NAMED_CSETS:
1025
+ entry = _NAMED_CSETS[colorset]
1026
+ cls_name = colorset.replace('-', '_').title().replace('_', '') + 'Cset'
1027
+ tuple_cls = namedtuple(cls_name, entry['fields'])
1028
+ return tuple_cls(*entry['hex'])
1029
+ if colorset in _UNNAMED_CSETS:
1030
+ return _UNNAMED_CSETS[colorset]
1031
+ raise ValueError(f"Unknown colorset {colorset!r}. Known sets: {CSET_NAMES}")
1032
+
1033
+
1034
+ def tol_cmap_colors(colormap='rainbow_PuRd', lut=None):
1035
+ """
1036
+ Return (colors, bad_hex, mode) for an ordered colormap without requiring matplotlib.
1037
+
1038
+ 'mode' is either 'linear' or 'discrete'.
1039
+ For 'rainbow_discrete', 'lut' selects the number of discrete stops (1..23, default 22).
1040
+ """
1041
+ if colormap is None:
1042
+ return OFFICIAL_CMAP_NAMES
1043
+ if colormap == 'rainbow_discrete' or colormap == 'rainbow-discrete':
1044
+ if lut is None or not isinstance(lut, int) or lut < 1 or lut > len(_RAINBOW_DISCRETE_LUT):
1045
+ lut = 22
1046
+ idxs = _RAINBOW_DISCRETE_LUT[lut - 1]
1047
+ clrs = tuple(_RAINBOW_DISCRETE_COLORS[i] for i in idxs)
1048
+ bad = _RAINBOW_DISCRETE_BAD.get(str(lut), _RAINBOW_DISCRETE_DEFAULT_BAD)
1049
+ return clrs, bad, 'discrete'
1050
+ normalized = colormap.replace('-', '_') if colormap not in _CMAPS else colormap
1051
+ if normalized in _CMAPS:
1052
+ entry = _CMAPS[normalized]
1053
+ return entry['colors'], entry['bad'], entry['mode']
1054
+ raise ValueError(f"Unknown colormap {colormap!r}. Known colormaps: {CMAP_NAMES}")
1055
+
1056
+
1057
+ def discretemap(colormap, hexclrs):
1058
+ """
1059
+ Produce a matplotlib colormap from a list of discrete colours without interpolation.
1060
+ Requires matplotlib and numpy.
1061
+ """
1062
+ import numpy as np
1063
+ from matplotlib.colors import LinearSegmentedColormap, to_rgba_array
1064
+
1065
+ clrs = to_rgba_array(list(hexclrs))
1066
+ clrs = np.vstack([clrs[0], clrs, clrs[-1]])
1067
+ cdict = {}
1068
+ for ki, key in enumerate(('red', 'green', 'blue')):
1069
+ cdict[key] = [
1070
+ (i / (len(clrs) - 2.0), float(clrs[i, ki]), float(clrs[i + 1, ki]))
1071
+ for i in range(len(clrs) - 1)
1072
+ ]
1073
+ return LinearSegmentedColormap(colormap, cdict)
1074
+
1075
+
1076
+ def tol_cmap(colormap=None, lut=None):
1077
+ """
1078
+ Return a matplotlib colormap for ordered data (continuous or discrete).
1079
+ When 'colormap' is None, returns 'OFFICIAL_CMAP_NAMES'.
1080
+ Requires matplotlib (imported lazily).
1081
+ """
1082
+ if colormap is None:
1083
+ return OFFICIAL_CMAP_NAMES
1084
+ from matplotlib.colors import LinearSegmentedColormap
1085
+
1086
+ clrs, bad, mode = tol_cmap_colors(colormap, lut=lut)
1087
+ if mode == 'discrete':
1088
+ cmap = discretemap(colormap, clrs)
1089
+ else:
1090
+ cmap = LinearSegmentedColormap.from_list(colormap, list(clrs))
1091
+ cmap.set_bad(bad)
1092
+ return cmap