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
VEGA_ACCENT
vega-accent
               
BOKEH_ACCENT
bokeh-accent
               
D3_ACCENT
d3-accent
               
VEGA_CATEGORY_10
vega-category-10
                   
BOKEH_CATEGORY_10
bokeh-category-10
                   
D3_CATEGORY_10
d3-category-10
                   
VEGA_CATEGORY_20
vega-category-20
                                       
BOKEH_CATEGORY_20
bokeh-category-20
                                       
VEGA_CATEGORY_20_B
vega-category-20-b
                                       
BOKEH_CATEGORY_20_B
bokeh-category-20-b
                                       
VEGA_CATEGORY_20_C
vega-category-20-c
                                       
BOKEH_CATEGORY_20_C
bokeh-category-20-c
                                       
VEGA_DARK_2
vega-dark-2
               
BOKEH_DARK_2
bokeh-dark-2
               
D3_DARK_2
d3-dark-2
               
VEGA_PAIRED
vega-paired
                       
BOKEH_PAIRED
bokeh-paired
                       
D3_PAIRED
d3-paired
                       
VEGA_PASTEL_1
vega-pastel-1
                 
BOKEH_PASTEL_1
bokeh-pastel-1
                 
D3_PASTEL_1
d3-pastel-1
                 
VEGA_PASTEL_2
vega-pastel-2
               
BOKEH_PASTEL_2
bokeh-pastel-2
               
D3_PASTEL_2
d3-pastel-2
               
VEGA_SET_1
vega-set-1
                 
BOKEH_SET_1
bokeh-set-1
                 
D3_SET_1
d3-set-1
                 
VEGA_SET_2
vega-set-2
               
BOKEH_SET_2
bokeh-set-2
               
D3_SET_2
d3-set-2
               
VEGA_SET_3
vega-set-3
                       
BOKEH_SET_3
bokeh-set-3
                       
D3_SET_3
d3-set-3
                       
VEGA_TABLEAU_10
vega-tableau-10
                   
D3_TABLEAU_10
d3-tableau-10
                   
VEGA_TABLEAU_20
vega-tableau-20
                                       
VEGA_OBSERVABLE_10
vega-observable-10
                   
D3_OBSERVABLE_10
d3-observable-10
                   
BOKEH_COLORBLIND
bokeh-colorblind
               

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
VEGA_BLUES
vega-blues
     
       
         
           
             
               
                 
BOKEH_BLUES
bokeh-blues
     
       
         
           
             
               
                 
D3_BLUES
d3-blues
     
       
         
           
             
               
                 
VEGA_TEAL_BLUES
vega-teal-blues
     
       
         
           
             
               
                 
VEGA_TEALS
vega-teals
     
       
         
           
             
               
                 
VEGA_GREENS
vega-greens
     
       
         
           
             
               
                 
BOKEH_GREENS
bokeh-greens
     
       
         
           
             
               
                 
D3_GREENS
d3-greens
     
       
         
           
             
               
                 
VEGA_BROWNS
vega-browns
     
       
         
           
             
               
                 
VEGA_ORANGES
vega-oranges
     
       
         
           
             
               
                 
BOKEH_ORANGES
bokeh-oranges
     
       
         
           
             
               
                 
D3_ORANGES
d3-oranges
     
       
         
           
             
               
                 
VEGA_REDS
vega-reds
     
       
         
           
             
               
                 
BOKEH_REDS
bokeh-reds
     
       
         
           
             
               
                 
D3_REDS
d3-reds
     
       
         
           
             
               
                 
VEGA_PURPLES
vega-purples
     
       
         
           
             
               
                 
BOKEH_PURPLES
bokeh-purples
     
       
         
           
             
               
                 
D3_PURPLES
d3-purples
     
       
         
           
             
               
                 
VEGA_WARM_GREYS
vega-warm-greys
     
       
         
           
             
               
                 
VEGA_GREYS
vega-greys
     
       
         
           
             
               
                 
BOKEH_GREYS
bokeh-greys
     
       
         
           
             
               
                 
D3_GREYS
d3-greys
     
       
         
           
             
               
                 
VEGA_VIRIDIS
vega-viridis
     
       
         
           
             
               
                 
BOKEH_VIRIDIS
bokeh-viridis
     
       
         
           
             
               
                 
D3_VIRIDIS
d3-viridis
     
       
         
           
             
               
                 
VEGA_MAGMA
vega-magma
     
       
         
           
             
               
                 
BOKEH_MAGMA
bokeh-magma
     
       
         
           
             
               
                 
D3_MAGMA
d3-magma
     
       
         
           
             
               
                 
VEGA_INFERNO
vega-inferno
     
       
         
           
             
               
                 
BOKEH_INFERNO
bokeh-inferno
     
       
         
           
             
               
                 
D3_INFERNO
d3-inferno
     
       
         
           
             
               
                 
VEGA_PLASMA
vega-plasma
     
       
         
           
             
               
                 
BOKEH_PLASMA
bokeh-plasma
     
       
         
           
             
               
                 
D3_PLASMA
d3-plasma
     
       
         
           
             
               
                 
VEGA_CIVIDIS
vega-cividis
     
       
         
           
             
               
                 
D3_CIVIDIS
d3-cividis
     
       
         
           
             
               
                 
VEGA_TURBO
vega-turbo
     
       
         
           
             
               
                 
D3_TURBO
d3-turbo
     
       
         
           
             
               
                 
D3_CUBEHELIX_DEFAULT
d3-cubehelix-default
     
       
         
           
             
               
                 
D3_WARM
d3-warm
     
       
         
           
             
               
                 
D3_COOL
d3-cool
     
       
         
           
             
               
                 
VEGA_BLUE_GREEN
vega-blue-green
     
       
         
           
             
               
                 
BOKEH_BLUE_GREEN
bokeh-blue-green
     
       
         
           
             
               
                 
D3_BLUE_GREEN
d3-blue-green
     
       
         
           
             
               
                 
VEGA_BLUE_PURPLE
vega-blue-purple
     
       
         
           
             
               
                 
BOKEH_BLUE_PURPLE
bokeh-blue-purple
     
       
         
           
             
               
                 
D3_BLUE_PURPLE
d3-blue-purple
     
       
         
           
             
               
                 
VEGA_GOLD_GREEN
vega-gold-green
     
       
         
           
             
               
                 
VEGA_GOLD_ORANGE
vega-gold-orange
     
       
         
           
             
               
                 
VEGA_GOLD_RED
vega-gold-red
     
       
         
           
             
               
                 
VEGA_GREEN_BLUE
vega-green-blue
     
       
         
           
             
               
                 
BOKEH_GREEN_BLUE
bokeh-green-blue
     
       
         
           
             
               
                 
D3_GREEN_BLUE
d3-green-blue
     
       
         
           
             
               
                 
VEGA_ORANGE_RED
vega-orange-red
     
       
         
           
             
               
                 
BOKEH_ORANGE_RED
bokeh-orange-red
     
       
         
           
             
               
                 
D3_ORANGE_RED
d3-orange-red
     
       
         
           
             
               
                 
VEGA_PURPLE_BLUE_GREEN
vega-purple-blue-green
     
       
         
           
             
               
                 
BOKEH_PURPLE_BLUE_GREEN
bokeh-purple-blue-green
     
       
         
           
             
               
                 
D3_PURPLE_BLUE_GREEN
d3-purple-blue-green
     
       
         
           
             
               
                 
VEGA_PURPLE_BLUE
vega-purple-blue
     
       
         
           
             
               
                 
BOKEH_PURPLE_BLUE
bokeh-purple-blue
     
       
         
           
             
               
                 
D3_PURPLE_BLUE
d3-purple-blue
     
       
         
           
             
               
                 
VEGA_PURPLE_RED
vega-purple-red
     
       
         
           
             
               
                 
BOKEH_PURPLE_RED
bokeh-purple-red
     
       
         
           
             
               
                 
D3_PURPLE_RED
d3-purple-red
     
       
         
           
             
               
                 
VEGA_RED_PURPLE
vega-red-purple
     
       
         
           
             
               
                 
BOKEH_RED_PURPLE
bokeh-red-purple
     
       
         
           
             
               
                 
D3_RED_PURPLE
d3-red-purple
     
       
         
           
             
               
                 
VEGA_YELLOW_GREEN_BLUE
vega-yellow-green-blue
     
       
         
           
             
               
                 
BOKEH_YELLOW_GREEN_BLUE
bokeh-yellow-green-blue
     
       
         
           
             
               
                 
D3_YELLOW_GREEN_BLUE
d3-yellow-green-blue
     
       
         
           
             
               
                 
VEGA_YELLOW_GREEN
vega-yellow-green
     
       
         
           
             
               
                 
BOKEH_YELLOW_GREEN
bokeh-yellow-green
     
       
         
           
             
               
                 
D3_YELLOW_GREEN
d3-yellow-green
     
       
         
           
             
               
                 
VEGA_YELLOW_ORANGE_BROWN
vega-yellow-orange-brown
     
       
         
           
             
               
                 
BOKEH_YELLOW_ORANGE_BROWN
bokeh-yellow-orange-brown
     
       
         
           
             
               
                 
D3_YELLOW_ORANGE_BROWN
d3-yellow-orange-brown
     
       
         
           
             
               
                 
VEGA_YELLOW_ORANGE_RED
vega-yellow-orange-red
     
       
         
           
             
               
                 
BOKEH_YELLOW_ORANGE_RED
bokeh-yellow-orange-red
     
       
         
           
             
               
                 
D3_YELLOW_ORANGE_RED
d3-yellow-orange-red
     
       
         
           
             
               
                 
VEGA_DARK_BLUE
vega-dark-blue
     
       
         
           
             
               
                 
VEGA_DARK_GOLD
vega-dark-gold
     
       
         
           
             
               
                 
VEGA_DARK_GREEN
vega-dark-green
     
       
         
           
             
               
                 
VEGA_DARK_MULTI
vega-dark-multi
     
       
         
           
             
               
                 
VEGA_DARK_RED
vega-dark-red
     
       
         
           
             
               
                 
VEGA_LIGHT_GREY_RED
vega-light-grey-red
     
       
         
           
             
               
                 
VEGA_LIGHT_GREY_TEAL
vega-light-grey-teal
     
       
         
           
             
               
                 
VEGA_LIGHT_MULTI
vega-light-multi
     
       
         
           
             
               
                 
VEGA_LIGHT_ORANGE
vega-light-orange
     
       
         
           
             
               
                 
VEGA_LIGHT_TEAL_BLUE
vega-light-teal-blue
     
       
         
           
             
               
                 

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
VEGA_BLUE_ORANGE
vega-blue-orange
     
         
             
                 
VEGA_BROWN_BLUE_GREEN
vega-brown-blue-green
     
         
             
                 
BOKEH_BROWN_BLUE_GREEN
bokeh-brown-blue-green
     
         
             
                 
D3_BROWN_BLUE_GREEN
d3-brown-blue-green
     
         
             
                 
VEGA_PURPLE_GREEN
vega-purple-green
     
         
             
                 
BOKEH_PURPLE_GREEN
bokeh-purple-green
     
         
             
                 
D3_PURPLE_GREEN
d3-purple-green
     
         
             
                 
VEGA_PINK_YELLOW_GREEN
vega-pink-yellow-green
     
         
             
                 
BOKEH_PINK_YELLOW_GREEN
bokeh-pink-yellow-green
     
         
             
                 
D3_PINK_YELLOW_GREEN
d3-pink-yellow-green
     
         
             
                 
VEGA_PURPLE_ORANGE
vega-purple-orange
     
         
             
                 
BOKEH_PURPLE_ORANGE
bokeh-purple-orange
     
         
             
                 
D3_PURPLE_ORANGE
d3-purple-orange
     
         
             
                 
VEGA_RED_BLUE
vega-red-blue
     
         
             
                 
BOKEH_RED_BLUE
bokeh-red-blue
     
         
             
                 
D3_RED_BLUE
d3-red-blue
     
         
             
                 
VEGA_RED_GREY
vega-red-grey
     
         
             
                 
BOKEH_RED_GREY
bokeh-red-grey
     
         
             
                 
D3_RED_GREY
d3-red-grey
     
         
             
                 
VEGA_RED_YELLOW_BLUE
vega-red-yellow-blue
     
         
             
                 
BOKEH_RED_YELLOW_BLUE
bokeh-red-yellow-blue
     
         
             
                 
D3_RED_YELLOW_BLUE
d3-red-yellow-blue
     
         
             
                 
VEGA_RED_YELLOW_GREEN
vega-red-yellow-green
     
         
             
                 
BOKEH_RED_YELLOW_GREEN
bokeh-red-yellow-green
     
         
             
                 
D3_RED_YELLOW_GREEN
d3-red-yellow-green
     
         
             
                 
VEGA_SPECTRAL
vega-spectral
     
         
             
                 
BOKEH_SPECTRAL
bokeh-spectral
     
         
             
                 
D3_SPECTRAL
d3-spectral
     
         
             
                 

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
VEGA_RAINBOW
vega-rainbow
D3_RAINBOW
d3-rainbow
VEGA_SINEBOW
vega-sinebow
D3_SINEBOW
d3-sinebow

References

  1. Color Schemes — Vega