Functional Weave
Code in TypeScript

charts.palette@1.0.0

README.md

1,961 bytes · view raw

# charts.palette

The colours for a chart's series: `palette("okabe-ito", 3, false)` is
`["#e69f00", "#56b4e9", "#009e73"]`. Both schemes are published sets chosen to
stay distinguishable to people with the common colour-vision deficiencies
(protanopia, deuteranopia) as well as to everyone else, which the default
rainbow palettes of many chart libraries are not.

- `okabe-ito`, 8 colours: orange, sky blue, bluish green, yellow, blue,
  vermillion, reddish purple, black (Okabe and Ito, "Color Universal Design").
  The published list starts with black; here black is moved to the end, so the
  first series are coloured and black stays free for axes and text until the
  eighth series. Otherwise the order and values are as published.
- `tol-bright`, 7 colours: blue, red, green, yellow, cyan, purple, grey, in
  Paul Tol's default order.

The colours are data (`data/palettes.json`, one row per colour with its
position and name), not code. They describe fixed published schemes rather
than rules that change over time, so the file has no `effective` columns and
is never pruned.

Asking for more colours than a scheme has is an error unless `cycle` is true:
a ninth series quietly reusing the first colour makes two series look like
one. With `cycle`, colours repeat from the start. All hex is lowercase
`#rrggbb`.

Sources: M. Okabe and K. Ito, "Color Universal Design (CUD): How to make
figures and presentations that are friendly to colorblind people" (2002, rev.
2008), https://jfly.uni-koeln.de/html/color_blind/ (RGB 0-255 values: black
0,0,0; orange 230,159,0; sky blue 86,180,233; bluish green 0,158,115; yellow
240,228,66; blue 0,114,178; vermillion 213,94,0; reddish purple 204,121,167);
B. Wong, "Points of view: Color blindness", Nature Methods 8, 441 (2011); P.
Tol, "Colour Schemes" (SRON technical note SRON/EPS/TN/09-002, 2021),
https://sronpersonalpages.nl/~pault/ (bright: #4477AA, #EE6677, #228833,
#CCBB44, #66CCEE, #AA3377, #BBBBBB).