Colormaps¶
Datoviz natively includes a collection of common colormaps, both continuous and discrete (color palettes). These colormaps come from the following sources:
- matplotlib
- bokeh
- colorcet
- Kenneth Moreland's page
These colormaps are stored in a 256x256 texture. Each row contains either:
- a 256-color continuous colormap,
- a 256-color discrete color palette,
- eight discrete 32-color palettes.
Unused space may be used for future or user-defined colormaps. The texture is always loaded both in CPU and GPU memory. It is shared between all visuals and canvases.
Datoviz provides a few functions to easily make colors out of scalar values:
import numpy as np
from datoviz import colormap
values = np.random.rand(1000)
colors = colormap(values, vmin=0, vmax=1, cmap='viridis')
print(colors)
# output:
# [[126 210 78 255]
# [ 64 68 135 255]
# [ 36 170 130 255]
# ...
# [ 36 132 141 255]
# [ 61 75 137 255]
# [ 31 148 139 255]]
DvzColormap cmap = DVZ_CMAP_VIRIDIS;
cvec4 color = {0};
uint8_t value = 128;
double dvalue = .5;
// Get a single color from a byte.
dvz_colormap(cmap, 128, color);
// Get a single color from a double, with a custom vmin-vmax range.
dvz_colormap_scale(cmap, dvalue, 0, 1, color);
// Get an array of colors from an array of values.
const uint32_t N = 10;
double* values = calloc(N, sizeof(double));
cvec4* colors = calloc(N, sizeof(cvec4));
dvz_colormap_array(cmap, N, values, 0, 1, colors);
FREE(values);
FREE(colors);
List of colormaps and color palettes¶
Note
The row and col give the offset of the colormap or color palette within the 256x256 colormap texture.
Name | Row, Col | Colormap |
---|---|---|
binary |
0, 0 | |
hsv |
1, 0 | |
cividis |
2, 0 | |
inferno |
3, 0 | |
magma |
4, 0 | |
plasma |
5, 0 | |
viridis |
6, 0 | |
blues |
7, 0 | |
bugn |
8, 0 | |
bupu |
9, 0 | |
gnbu |
10, 0 | |
greens |
11, 0 | |
greys |
12, 0 | |
oranges |
13, 0 | |
orrd |
14, 0 | |
pubu |
15, 0 | |
pubugn |
16, 0 | |
purples |
17, 0 | |
rdpu |
18, 0 | |
reds |
19, 0 | |
ylgn |
20, 0 | |
ylgnbu |
21, 0 | |
ylorbr |
22, 0 | |
ylorrd |
23, 0 | |
afmhot |
24, 0 | |
autumn |
25, 0 | |
bone |
26, 0 | |
cool |
27, 0 | |
copper |
28, 0 | |
gist_heat |
29, 0 | |
gray |
30, 0 | |
hot |
31, 0 | |
pink |
32, 0 | |
spring |
33, 0 | |
summer |
34, 0 | |
winter |
35, 0 | |
wistia |
36, 0 | |
brbg |
37, 0 | |
bwr |
38, 0 | |
coolwarm |
39, 0 | |
piyg |
40, 0 | |
prgn |
41, 0 | |
puor |
42, 0 | |
rdbu |
43, 0 | |
rdgy |
44, 0 | |
rdylbu |
45, 0 | |
rdylgn |
46, 0 | |
seismic |
47, 0 | |
spectral |
48, 0 | |
twilight_shifted |
49, 0 | |
twilight |
50, 0 | |
brg |
51, 0 | |
cmrmap |
52, 0 | |
cubehelix |
53, 0 | |
flag |
54, 0 | |
gist_earth |
55, 0 | |
gist_ncar |
56, 0 | |
gist_rainbow |
57, 0 | |
gist_stern |
58, 0 | |
gnuplot2 |
59, 0 | |
gnuplot |
60, 0 | |
jet |
61, 0 | |
nipy_spectral |
62, 0 | |
ocean |
63, 0 | |
prism |
64, 0 | |
rainbow |
65, 0 | |
terrain |
66, 0 | |
bkr |
67, 0 | |
bky |
68, 0 | |
cet_d10 |
69, 0 | |
cet_d11 |
70, 0 | |
cet_d8 |
71, 0 | |
cet_d13 |
72, 0 | |
cet_d3 |
73, 0 | |
cet_d1a |
74, 0 | |
bjy |
75, 0 | |
gwv |
76, 0 | |
bwy |
77, 0 | |
cet_d12 |
78, 0 | |
cet_r3 |
79, 0 | |
cet_d9 |
80, 0 | |
cwr |
81, 0 | |
cet_cbc1 |
82, 0 | |
cet_cbc2 |
83, 0 | |
cet_cbl1 |
84, 0 | |
cet_cbl2 |
85, 0 | |
cet_cbtc1 |
86, 0 | |
cet_cbtc2 |
87, 0 | |
cet_cbtl1 |
88, 0 | |
bgy |
89, 0 | |
bgyw |
90, 0 | |
bmw |
91, 0 | |
cet_c1 |
92, 0 | |
cet_c1s |
93, 0 | |
cet_c2 |
94, 0 | |
cet_c4 |
95, 0 | |
cet_c4s |
96, 0 | |
cet_c5 |
97, 0 | |
cet_i1 |
98, 0 | |
cet_i3 |
99, 0 | |
cet_l10 |
100, 0 | |
cet_l11 |
101, 0 | |
cet_l12 |
102, 0 | |
cet_l16 |
103, 0 | |
cet_l17 |
104, 0 | |
cet_l18 |
105, 0 | |
cet_l19 |
106, 0 | |
cet_l4 |
107, 0 | |
cet_l7 |
108, 0 | |
cet_l8 |
109, 0 | |
cet_l9 |
110, 0 | |
cet_r1 |
111, 0 | |
cet_r2 |
112, 0 | |
colorwheel |
113, 0 | |
fire |
114, 0 | |
isolum |
115, 0 | |
kb |
116, 0 | |
kbc |
117, 0 | |
kg |
118, 0 | |
kgy |
119, 0 | |
kr |
120, 0 | |
black_body |
121, 0 | |
kindlmann |
122, 0 | |
extended_kindlmann |
123, 0 | |
glasbey |
176, 0 | |
glasbey_cool |
177, 0 | |
glasbey_dark |
178, 0 | |
glasbey_hv |
179, 0 | |
glasbey_light |
180, 0 | |
glasbey_warm |
181, 0 | |
accent |
240, 0 | |
dark2 |
240, 32 | |
paired |
240, 64 | |
pastel1 |
240, 96 | |
pastel2 |
240, 128 | |
set1 |
240, 160 | |
set2 |
240, 192 | |
set3 |
240, 224 | |
tab10 |
241, 0 | |
tab20 |
241, 32 | |
tab20b |
241, 64 | |
tab20c |
241, 96 | |
category10_10 |
241, 128 | |
category20_20 |
241, 160 | |
category20b_20 |
241, 192 | |
category20c_20 |
241, 224 | |
colorblind8 |
242, 0 |