Skip to content

Colorscales & palettes ​

Every colorscale and palette name that Holochart knows, drawn from its stops. The lists on this page are generated from the library's color registries. How colors, colorscales and colorbars work is in Colors, colorscales & colorbars.

Holochart has 94 named colorscales (65 sequential, 22 diverging, 7 cyclical) and 21 qualitative palettes.

Using a name ​

A colorscale name goes in a colorscale attribute, and a palette name in layout.colorway:

ts
import { createChart } from '@mk7s/holochart';

createChart(el, {
  data: [
    {
      type: 'scatter',
      mode: 'markers',
      x: [1, 2, 3, 4],
      y: [3, 1, 4, 2],
      marker: { color: [12.5, 17.1, 21.8, 26.4], colorscale: 'Viridis', showscale: true },
    },
  ],
  layout: { colorway: 'Bold' },
});
  • Names are not case-sensitive: 'viridis' is 'Viridis'.
  • Add _r to a colorscale name to reverse it: 'Viridis_r'. Setting reversescale: true next to the colorscale does the same. Palettes have no reversed names.
  • A colorscale also takes its own stops, [position, color] pairs that start at 0 and end at 1: [[0, 'navy'], [0.8, 'gold'], [1, 'white']].
  • A colorscale name that doesn't resolve is not reported as an invalid value. With marker.colorscale, the trace is drawn with the automatic colorscale, as if colorscale were not set. A palette name that doesn't resolve is reported as an invalid layout.colorway, and the default colorway is used.

These attributes take a colorscale:

AttributeIn
fillgradient.colorscalescatter
marker.colorscalescatter, bar, histogram, splom, scatterpolar, barpolar, funnel, sunburst, treemap, icicle, scatter3d, bar3d
marker.line.colorscalescatter, bar, histogram, splom, scatterpolar, barpolar, funnel, scatter3d
colorscalehistogram2d, histogram2dcontour, heatmap, contour, surface, mesh3d, cone, streamtube, isosurface, volume
line.colorscaleparcoords, parcats, scatter3d
link.colorscales[].colorscalesankey
layout.colorscale.sequentialThe layout
layout.colorscale.sequentialminusThe layout
layout.colorscale.divergingThe layout
layout.coloraxis.colorscaleThe layout

A palette name works in these layout attributes: layout.colorway, layout.piecolorway, layout.funnelareacolorway, layout.sunburstcolorway, layout.treemapcolorway, layout.iciclecolorway.

The palettes are also exported as arrays, so you can slice or reorder them: colorway: QUALITATIVE.Bold is the same as colorway: 'Bold'.

Your own names ​

colors.register adds a colorscale and colorways.register adds a palette. Register a name before you plot a figure that uses it.

ts
import { colors, colorways } from '@mk7s/holochart';

// A list of colors is spread evenly from 0 to 1.
colors.register('Brand', ['#0b1f3a', '#1d6fa5', '#9ad0ec']);
// Or give the stops.
const unregister = colors.register('Traffic', [
  [0, 'seagreen'],
  [0.6, 'gold'],
  [1, 'crimson'],
]);
colorways.register('Team', ['#ea2a37', '#5e74d5', '#118e36']);

createChart(el, {
  data: [
    {
      type: 'scatter',
      mode: 'markers',
      y: [1, 3, 2],
      marker: { color: [1, 3, 2], colorscale: 'Brand_r' },
    },
  ],
  layout: { colorway: 'Team' },
});

unregister(); // 'Traffic' no longer resolves

Both functions return a function that removes the name again. Registering a name that exists replaces it, whatever its case. A registered scale gets its _r name for free, unless you register a scale under that exact name.

colors.get(name) returns the stops of a scale and colorways.get(name) the colors of a palette, or undefined. colors.has(name) tells whether a name resolves, colors.names() and colorways.names() list the names, and colors.reverse(stops) mirrors a scale.

Partial bundles ​

The full @mk7s/holochart bundle registers every name on this page when it loads. A partial bundle starts with these:

  • 19 colorscales: Greys, YlGnBu, Greens, YlOrRd, Bluered, RdBu, Reds, Blues, Picnic, Rainbow, Portland, Jet, Hot, Blackbody, Earth, Electric, Viridis, Cividis, Plasma
  • 1 palette: Safe

Register the rest, or only the sets you use:

ts
import { CMOCEAN_SEQUENTIAL, colors, registerBuiltinColors } from '@mk7s/holochart-core';

registerBuiltinColors(); // every colorscale and palette on this page

// Or one set, here cmocean's sequential scales:
colors.registerAll(CMOCEAN_SEQUENTIAL, { overwrite: false });

With overwrite: false, a name that already resolves keeps its meaning. That is how registerBuiltinColors adds the sets, and why some names don't resolve to the list of the same name.

The sets that add colorscale names are SEQUENTIAL, COLORBREWER_SEQUENTIAL, COLORBREWER_DIVERGING, CMOCEAN_SEQUENTIAL, CMOCEAN_DIVERGING, CMOCEAN_CYCLICAL, CARTO_SEQUENTIAL, CARTO_DIVERGING, CYCLICAL, and the palettes are in QUALITATIVE. All of them are exported by @mk7s/holochart too.

Reading the tables ​

Source is the set a colorscale comes from: plotly.js for plotly.js' own names and Plasma (the ones every bundle has), plotly for plotly.py's own scales, and ColorBrewer, cmocean and CARTO for the sets plotly.py takes from those projects. Each swatch is drawn from the scale's stops, with colors between stops blended in sRGB, as charts draw them unless layout.colorscaleInterpolation says otherwise. Hover a color of a palette to read its value.

Sequential colorscales ​

NameSourceScale
Greysplotly.js
YlGnBuplotly.js
Greensplotly.js
YlOrRdplotly.js
Blueredplotly.js
Redsplotly.js
Bluesplotly.js
Rainbowplotly.js
Jetplotly.js
Hotplotly.js
Blackbodyplotly.js
Electricplotly.js
Viridisplotly.js
Cividisplotly.js
Plasmaplotly.js
Plotly3plotly
Infernoplotly
Magmaplotly
Turboplotly
BuGnColorBrewer
BuPuColorBrewer
GnBuColorBrewer
OrRdColorBrewer
OrangesColorBrewer
PuBuColorBrewer
PuBuGnColorBrewer
PuRdColorBrewer
PurplesColorBrewer
RdPuColorBrewer
YlGnColorBrewer
YlOrBrColorBrewer
turbidcmocean
thermalcmocean
halinecmocean
solarcmocean
icecmocean
graycmocean
deepcmocean
densecmocean
algaecmocean
mattercmocean
speedcmocean
ampcmocean
tempocmocean
BurgCARTO
BurgylCARTO
RedorCARTO
OryelCARTO
PeachCARTO
PinkylCARTO
MintCARTO
BlugrnCARTO
DarkmintCARTO
EmrldCARTO
AggrnylCARTO
BluylCARTO
TealCARTO
TealgrnCARTO
PurpCARTO
PurporCARTO
SunsetCARTO
MagentaCARTO
SunsetdarkCARTO
AgsunsetCARTO
BrwnylCARTO

Diverging colorscales ​

NameSourceScale
RdBuplotly.js
Picnicplotly.js
Portlandplotly.js
Earthplotly.js
BrBGColorBrewer
PRGnColorBrewer
PiYGColorBrewer
PuOrColorBrewer
RdGyColorBrewer
RdYlBuColorBrewer
RdYlGnColorBrewer
SpectralColorBrewer
balancecmocean
deltacmocean
curlcmocean
oxycmocean
ArmyroseCARTO
FallCARTO
GeyserCARTO
TealroseCARTO
TempsCARTO
TropicCARTO

Cyclical colorscales ​

NameSourceScale
phasecmocean
Twilightplotly
IceFireplotly
Edgeplotly
HSVplotly
mrybmplotly
mygbmplotly

Names with two definitions ​

20 lists of the built-in sets share a name (ignoring case) with a scale that comes earlier in the registry. The name keeps the earlier meaning; the other list is exported as a value.

NameResolves toOther list
Viridisplotly.jsSEQUENTIAL.Viridis
Cividisplotly.jsSEQUENTIAL.Cividis
Plasmaplotly.jsSEQUENTIAL.Plasma
Rainbowplotly.jsSEQUENTIAL.Rainbow
Blackbodyplotly.jsSEQUENTIAL.Blackbody
Blueredplotly.jsSEQUENTIAL.Bluered
Electricplotly.jsSEQUENTIAL.Electric
Hotplotly.jsSEQUENTIAL.Hot
Jetplotly.jsSEQUENTIAL.Jet
Picnicplotly.jsDIVERGING_PLOTLY.Picnic
Portlandplotly.jsDIVERGING_PLOTLY.Portland
Bluesplotly.jsCOLORBREWER_SEQUENTIAL.Blues
Greensplotly.jsCOLORBREWER_SEQUENTIAL.Greens
Greysplotly.jsCOLORBREWER_SEQUENTIAL.Greys
Redsplotly.jsCOLORBREWER_SEQUENTIAL.Reds
YlGnBuplotly.jsCOLORBREWER_SEQUENTIAL.YlGnBu
YlOrRdplotly.jsCOLORBREWER_SEQUENTIAL.YlOrRd
RdBuplotly.jsCOLORBREWER_DIVERGING.RdBu
Earthplotly.jsCARTO_DIVERGING.Earth
phasecmoceanCYCLICAL.Phase

Qualitative palettes ​

NameColorsPalette
Plotly10
D310
G1010
T1010
Alphabet26
Dark2424
Light2424
Set19
Pastel19
Dark28
Set28
Pastel28
Set312
Antique11
Bold11
Pastel11
Prism11
Safe11
Vivid11
Accent8
Paired12

Defaults ​

A figure that sets neither layout.template nor these attributes gets them from the holochart template:

AttributeDefault
layout.colorway
layout.colorscale.sequential
layout.colorscale.sequentialminus
layout.colorscale.diverging

Other templates set their own colorway and automatic colorscales: see Themes & templates.

Released under the MIT License.