Skip to content

Colormaps

Datoviz natively includes a collection of common colormaps, both continuous and discrete (color palettes). These colormaps come from the following sources:

Colormap texture 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 BINARY
hsv 1, 0 HSV
cividis 2, 0 CIVIDIS
inferno 3, 0 INFERNO
magma 4, 0 MAGMA
plasma 5, 0 PLASMA
viridis 6, 0 VIRIDIS
blues 7, 0 BLUES
bugn 8, 0 BUGN
bupu 9, 0 BUPU
gnbu 10, 0 GNBU
greens 11, 0 GREENS
greys 12, 0 GREYS
oranges 13, 0 ORANGES
orrd 14, 0 ORRD
pubu 15, 0 PUBU
pubugn 16, 0 PUBUGN
purples 17, 0 PURPLES
rdpu 18, 0 RDPU
reds 19, 0 REDS
ylgn 20, 0 YLGN
ylgnbu 21, 0 YLGNBU
ylorbr 22, 0 YLORBR
ylorrd 23, 0 YLORRD
afmhot 24, 0 AFMHOT
autumn 25, 0 AUTUMN
bone 26, 0 BONE
cool 27, 0 COOL
copper 28, 0 COPPER
gist_heat 29, 0 GIST_HEAT
gray 30, 0 GRAY
hot 31, 0 HOT
pink 32, 0 PINK
spring 33, 0 SPRING
summer 34, 0 SUMMER
winter 35, 0 WINTER
wistia 36, 0 WISTIA
brbg 37, 0 BRBG
bwr 38, 0 BWR
coolwarm 39, 0 COOLWARM
piyg 40, 0 PIYG
prgn 41, 0 PRGN
puor 42, 0 PUOR
rdbu 43, 0 RDBU
rdgy 44, 0 RDGY
rdylbu 45, 0 RDYLBU
rdylgn 46, 0 RDYLGN
seismic 47, 0 SEISMIC
spectral 48, 0 SPECTRAL
twilight_shifted 49, 0 TWILIGHT_SHIFTED
twilight 50, 0 TWILIGHT
brg 51, 0 BRG
cmrmap 52, 0 CMRMAP
cubehelix 53, 0 CUBEHELIX
flag 54, 0 FLAG
gist_earth 55, 0 GIST_EARTH
gist_ncar 56, 0 GIST_NCAR
gist_rainbow 57, 0 GIST_RAINBOW
gist_stern 58, 0 GIST_STERN
gnuplot2 59, 0 GNUPLOT2
gnuplot 60, 0 GNUPLOT
jet 61, 0 JET
nipy_spectral 62, 0 NIPY_SPECTRAL
ocean 63, 0 OCEAN
prism 64, 0 PRISM
rainbow 65, 0 RAINBOW
terrain 66, 0 TERRAIN
bkr 67, 0 BKR
bky 68, 0 BKY
cet_d10 69, 0 CET_D10
cet_d11 70, 0 CET_D11
cet_d8 71, 0 CET_D8
cet_d13 72, 0 CET_D13
cet_d3 73, 0 CET_D3
cet_d1a 74, 0 CET_D1A
bjy 75, 0 BJY
gwv 76, 0 GWV
bwy 77, 0 BWY
cet_d12 78, 0 CET_D12
cet_r3 79, 0 CET_R3
cet_d9 80, 0 CET_D9
cwr 81, 0 CWR
cet_cbc1 82, 0 CET_CBC1
cet_cbc2 83, 0 CET_CBC2
cet_cbl1 84, 0 CET_CBL1
cet_cbl2 85, 0 CET_CBL2
cet_cbtc1 86, 0 CET_CBTC1
cet_cbtc2 87, 0 CET_CBTC2
cet_cbtl1 88, 0 CET_CBTL1
bgy 89, 0 BGY
bgyw 90, 0 BGYW
bmw 91, 0 BMW
cet_c1 92, 0 CET_C1
cet_c1s 93, 0 CET_C1S
cet_c2 94, 0 CET_C2
cet_c4 95, 0 CET_C4
cet_c4s 96, 0 CET_C4S
cet_c5 97, 0 CET_C5
cet_i1 98, 0 CET_I1
cet_i3 99, 0 CET_I3
cet_l10 100, 0 CET_L10
cet_l11 101, 0 CET_L11
cet_l12 102, 0 CET_L12
cet_l16 103, 0 CET_L16
cet_l17 104, 0 CET_L17
cet_l18 105, 0 CET_L18
cet_l19 106, 0 CET_L19
cet_l4 107, 0 CET_L4
cet_l7 108, 0 CET_L7
cet_l8 109, 0 CET_L8
cet_l9 110, 0 CET_L9
cet_r1 111, 0 CET_R1
cet_r2 112, 0 CET_R2
colorwheel 113, 0 COLORWHEEL
fire 114, 0 FIRE
isolum 115, 0 ISOLUM
kb 116, 0 KB
kbc 117, 0 KBC
kg 118, 0 KG
kgy 119, 0 KGY
kr 120, 0 KR
black_body 121, 0 BLACK_BODY
kindlmann 122, 0 KINDLMANN
extended_kindlmann 123, 0 EXTENDED_KINDLMANN
glasbey 176, 0 GLASBEY
glasbey_cool 177, 0 GLASBEY_COOL
glasbey_dark 178, 0 GLASBEY_DARK
glasbey_hv 179, 0 GLASBEY_HV
glasbey_light 180, 0 GLASBEY_LIGHT
glasbey_warm 181, 0 GLASBEY_WARM
accent 240, 0 ACCENT
dark2 240, 32 DARK2
paired 240, 64 PAIRED
pastel1 240, 96 PASTEL1
pastel2 240, 128 PASTEL2
set1 240, 160 SET1
set2 240, 192 SET2
set3 240, 224 SET3
tab10 241, 0 TAB10
tab20 241, 32 TAB20
tab20b 241, 64 TAB20B
tab20c 241, 96 TAB20C
category10_10 241, 128 CATEGORY10_10
category20_20 241, 160 CATEGORY20_20
category20b_20 241, 192 CATEGORY20B_20
category20c_20 241, 224 CATEGORY20C_20
colorblind8 242, 0 COLORBLIND8