chrys
Installation
Node.js
npm install chrys
Python
pip install chrys
Sass
npm install chrys
Usage
Get a list of colours
Omit n to return every available colour: discrete palettes return their largest available size; continuous palettes return the full 256-colour ramp. Pass n to limit the result, or mode to override automatic continuous/discrete selection.
Node.js
import {VEGA_ACCENT, getPaletteColors} from 'chrys';
const colors = getPaletteColors(VEGA_ACCENT);
["#7fc97f", "#beaed4", "#fdc086", "#ffff99", "#386cb0", "#f0027f", "#bf5b17", "#666666"]
import {VEGA_VIRIDIS, getPaletteColors} from 'chrys';
const colors = getPaletteColors(VEGA_VIRIDIS, 5, 'discrete');
["#443a83", "#31688e", "#21918d", "#35b779", "#8fd744"]
Python
from chrys.palettes import VEGA_ACCENT
from chrys.utils import get_palette_colors
hex_colors = get_palette_colors(VEGA_ACCENT)
["#7fc97f", "#beaed4", "#fdc086", "#ffff99", "#386cb0", "#f0027f", "#bf5b17", "#666666"]
from chrys.palettes import VEGA_VIRIDIS
from chrys.utils import PaletteMode, get_palette_colors
hex_colors = get_palette_colors(VEGA_VIRIDIS, n=5, mode=PaletteMode.DISCRETE)
["#443a83", "#31688e", "#21918d", "#35b779", "#8fd744"]
Sass
@import 'node_modules/chrys/src/variables';
$palette: map-get(map-get($chrys-palettes, 'vega-accent'), 5);
["#7fc97f", "#beaed4", "#fdc086", "#ffff99", "#386cb0"]
Import a single palette
Import only the utility and palette data you need to keep JavaScript bundles small.
Node.js
import toDiscreteColors from 'chrys/utils/to-discrete-colors';
import {BOKEH_VIRIDIS_PALETTE_DATA} from 'chrys/palettes/bokeh/viridis';
const colors = toDiscreteColors(BOKEH_VIRIDIS_PALETTE_DATA, 6);
["#440154", "#404387", "#29788e", "#22a784", "#79d151", "#fde724"]
getPaletteColors(name, n, mode) resolves names through the full palette registry and includes all palette data. mode accepts auto (default), continuous, or discrete. Use toDiscreteColors or toContinuousColors with an explicit *_PALETTE_DATA constant when bundle size matters.
Get a list of qualified palette names
Node.js
import {VEGA_PALETTE_NAMES} from 'chrys';
const variables = Object.keys(VEGA_PALETTE_NAMES);
const names = Object.values(VEGA_PALETTE_NAMES);
["VEGA_GREENS", "VEGA_YELLOW_GREEN", "VEGA_GOLD_GREEN", ...]
["vega_greens", "vega_yellowgreen", "vega_goldgreen", ...]
Python
from chrys.palettes import VEGA_PALETTE_NAMES
variables = VEGA_PALETTE_NAMES.keys()
names = VEGA_PALETTE_NAMES.values()
["VEGA_GREENS", "VEGA_YELLOW_GREEN", "VEGA_GOLD_GREEN", ...]
["vega_greens", "vega_yellowgreen", "vega_goldgreen", ...]
Parse a qualified palette name
Get the vendor and the vendor-specific palette name used internally by the vendor. For example, in Altair and Vega, this is the scheme name.
Node.js
import {VEGA_ACCENT, parsePaletteName} from 'chrys';
parsePaletteName(VEGA_ACCENT);
{vendor: "vega", palette: "accent"}
Python
from chrys.palettes import VEGA_CATEGORY_10
from chrys.utils import parse_palette_name
vendor, name = parse_palette_name(VEGA_CATEGORY_10)
("vega", "category10")
Colour schemes
Categorical schemes
Categorical colour schemes can be used to encode discrete data values, each representing a distinct category.[1]
| Vega | Bokeh | D3 | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Variable name | Palette | Variable name | Palette | Variable name | Palette | ||||||||||||
|
|
|
|
|
|
||||||||||||
|
|
|
|
|
|
||||||||||||
|
|
|
|
||||||||||||||
|
|
|
|
||||||||||||||
|
|
|
|
||||||||||||||
|
|
|
|
|
|
||||||||||||
|
|
|
|
|
|
||||||||||||
|
|
|
|
|
|
||||||||||||
|
|
|
|
|
|
||||||||||||
|
|
|
|
|
|
||||||||||||
|
|
|
|
|
|
||||||||||||
|
|
|
|
|
|
||||||||||||
|
|
|
|
||||||||||||||
|
|
||||||||||||||||
|
|
|
|
||||||||||||||
|
|
||||||||||||||||
Sequential schemes
Sequential colour schemes can be used to encode quantitative values. These colour ramps are designed to encode increasing numeric values. Multi-hue schemes use additional hues for more colour discrimination, which may be useful for visualisations such as heatmaps. However, beware that using multiple hues may cause viewers to inaccurately see the data range as grouped into colour-coded clusters.[1]
| Vega | Bokeh | D3 | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Variable name | Palette | Variable name | Palette | Variable name | Palette | ||||||||||||
|
|
|
|
|
|
||||||||||||
|
|
||||||||||||||||
|
|
||||||||||||||||
|
|
|
|
|
|
||||||||||||
|
|
||||||||||||||||
|
|
|
|
|
|
||||||||||||
|
|
|
|
|
|
||||||||||||
|
|
|
|
|
|
||||||||||||
|
|
||||||||||||||||
|
|
|
|
|
|
||||||||||||
|
|
|
|
|
|
||||||||||||
|
|
|
|
|
|
||||||||||||
|
|
|
|
|
|
||||||||||||
|
|
|
|
|
|
||||||||||||
|
|
|
|
||||||||||||||
|
|
|
|
||||||||||||||
|
|
||||||||||||||||
|
|
||||||||||||||||
|
|
||||||||||||||||
|
|
|
|
|
|
||||||||||||
|
|
|
|
|
|
||||||||||||
|
|
||||||||||||||||
|
|
||||||||||||||||
|
|
||||||||||||||||
|
|
|
|
|
|
||||||||||||
|
|
|
|
|
|
||||||||||||
|
|
|
|
|
|
||||||||||||
|
|
|
|
|
|
||||||||||||
|
|
|
|
|
|
||||||||||||
|
|
|
|
|
|
||||||||||||
|
|
|
|
|
|
||||||||||||
|
|
|
|
|
|
||||||||||||
|
|
|
|
|
|
||||||||||||
|
|
|
|
|
|
||||||||||||
|
|
||||||||||||||||
|
|
||||||||||||||||
|
|
||||||||||||||||
|
|
||||||||||||||||
|
|
||||||||||||||||
|
|
||||||||||||||||
|
|
||||||||||||||||
|
|
||||||||||||||||
|
|
||||||||||||||||
|
|
||||||||||||||||
Diverging schemes
Diverging colour schemes can be used to encode quantitative values with a meaningful mid-point, such as zero or the average value. Color ramps with different hues diverge with increasing saturation to highlight the values below and above the mid-point.[1]
| Vega | Bokeh | D3 | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Variable name | Palette | Variable name | Palette | Variable name | Palette | ||||||||||||
|
|
||||||||||||||||
|
|
|
|
|
|
||||||||||||
|
|
|
|
|
|
||||||||||||
|
|
|
|
|
|
||||||||||||
|
|
|
|
|
|
||||||||||||
|
|
|
|
|
|
||||||||||||
|
|
|
|
|
|
||||||||||||
|
|
|
|
|
|
||||||||||||
|
|
|
|
|
|
||||||||||||
|
|
|
|
|
|
||||||||||||
Cyclical schemes
Cyclical colour schemes may be used to highlight periodic patterns in continuous data. However, these schemes are not well suited to accurately convey value differences.[1]
| Vega | Bokeh | D3 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Variable name | Palette | Variable name | Palette | Variable name | Palette | ||||||||
|
|
||||||||||||
|
|
||||||||||||