Color Palettes
A Palette is a named, ordered list of colors that auto-cycles across plots. Palettes are used to assign consistent, visually distinct colors to multiple series without specifying each one manually.
Using a palette
Auto-cycle across plots
Pass a palette to Layout::with_palette() and kuva assigns colors in order to each plot that does not already have an explicit color set:
#![allow(unused)] fn main() { use kuva::render::layout::Layout; use kuva::render::palette::Palette; let layout = Layout::auto_from_plots(&plots) .with_palette(Palette::wong()); }
Manual indexing
Index directly into a palette with []. Indexing wraps with modulo, so pal[n] is always valid regardless of palette size:
#![allow(unused)] fn main() { let pal = Palette::tol_bright(); let color_a = &pal[0]; // "#4477AA" let color_b = &pal[1]; // "#EE6677" let color_c = &pal[7]; // wraps: same as pal[0] }
CLI
kuva scatter data.tsv --x x --y y --palette wong
kuva line data.tsv --x-col time --y-col value --color-by group --palette tol_muted
Available CLI values: wong, okabe_ito, tol_bright, tol_muted, tol_light, ibm, category10, pastel, bold, plus the LTC palettes below: paloma, maya, dora, ploen, olga, mterese, franscoise, fernande, sylvie, expevo, minou, alger, seafarer, luminaries, casa-natal (an optional ltc- prefix is accepted, e.g. ltc-maya).
For convenience, --cvd-palette TYPE selects a colorblind-safe palette by condition name: deuteranopia, protanopia, tritanopia.
Built-in palettes
Colorblind-safe
| Constructor | N | Colors |
|---|---|---|
Palette::wong() | 8 | #E69F00 #56B4E9 #009E73 #F0E442 #0072B2 #D55E00 #CC79A7 #000000 |
Palette::okabe_ito() | 8 | Same as Wong — widely known by both names |
Palette::tol_bright() | 7 | #4477AA #EE6677 #228833 #CCBB44 #66CCEE #AA3377 #BBBBBB |
Palette::tol_muted() | 10 | #CC6677 #332288 #DDCC77 #117733 #88CCEE #882255 #44AA99 #999933 #AA4499 #DDDDDD |
Palette::tol_light() | 9 | #77AADD #EE8866 #EEDD88 #FFAABB #99DDFF #44BB99 #BBCC33 #AAAA00 #DDDDDD |
Palette::ibm() | 5 | #648FFF #785EF0 #DC267F #FE6100 #FFB000 |
Recommendations:
wong/okabe_ito— best general choice; safe for deuteranopia and protanopia (~7% of males)tol_bright— safe for tritanopia; good for presentationstol_muted— 10 colors for larger datasets; safe for all common CVD typesibm— compact 5-color set from the IBM Design Language
Colorblind condition aliases
These are convenience constructors that return an appropriate palette for a specific condition:
| Constructor | Returns | Safe for |
|---|---|---|
Palette::deuteranopia() | Wong | Red-green (~6% of males) |
Palette::protanopia() | Wong | Red-green (~1% of males) |
Palette::tritanopia() | Tol Bright | Blue-yellow (rare) |
General-purpose
| Constructor | N | Colors |
|---|---|---|
Palette::category10() | 10 | #1f77b4 #ff7f0e #2ca02c #d62728 #9467bd #8c564b #e377c2 #7f7f7f #bcbd22 #17becf |
Palette::pastel() | 10 | #aec7e8 #ffbb78 #98df8a #ff9896 #c5b0d5 #c49c94 #f7b6d2 #c7c7c7 #dbdb8d #9edae5 |
Palette::bold() | 10 | #e41a1c #377eb8 #4daf4a #984ea3 #ff7f00 #a65628 #f781bf #999999 #66c2a5 #fc8d62 |
category10 is the default when no palette is set.
LTC palettes
Curated qualitative palettes from loukesio/ltc-color-palettes (MIT licensed), named after Picasso's muses and a few places. They are hand-picked for small-cardinality categorical series where the ColorBrewer/Tableau defaults feel clinical. Hex values are shown so you can lift them directly.
Palette::paloma() (5 colours): soft coral, sage, and butter
#83AF9B #C8C8A9 #F8DA8A #F7BF95 #FE8CA1
Palette::maya() (5 colours): navy, sky, ice, coral, ink
#3D5A80 #98C1D9 #E0FBFC #EE6C4D #293241
Palette::dora() (5 colours): teal, plum, and warm reds
#52777A #542437 #C02942 #D95B43 #ECD078
Palette::ploen() (5 colours): slate blues, mauve, and peach
#3F5671 #83A1C3 #CEB5C8 #FAC898 #B17776
Palette::olga() (5 colours): pastel green, teal, gold, apricot, mauve
#C9E3C2 #8BC8CB #ECCD80 #F5AB70 #9C87A1
Palette::mterese() (5 colours): cream, apricot, pink, and cornflower
#F7DDAA #FAC3AD #F897A1 #9298BA #9CBEED
Palette::franscoise() (5 colours): blues, mauve, and warm reds
#5980B1 #B96A8D #A55062 #E05256 #E9A986
Palette::fernande() (4 colours): coral, yellow, green, blue
#FF7676 #F9D662 #7CAB7D #75B7D1
Palette::sylvie() (5 colours): gold, coral, lavender, teal, pink
#E8B961 #E88170 #C6BDE8 #5DB7C4 #FD95BC
Palette::expevo() (6 colours): high-contrast orange, gold, teal, plum, navy, grey
#FC4E07 #E7B800 #00AFBB #8B4769 #1D457F #808080
Palette::minou() (6 colours): teal, red, gold, green, ink, slate
#00798C #D1495B #EDAE49 #66A182 #2E4057 #8D96A3
Palette::alger() (5 colours): black, teal, sage, gold, red
#000000 #1A5B5B #ACC8BE #F4AB5C #D1422F
Palette::seafarer() (5 colours): deep teal, cream, sage, moss, sand
#013D5A #FCF3E3 #BDD3CE #708C69 #E4A25B
Palette::luminaries() (6 colours): orange, teal, charcoal, ivory, gold, mist
#FF5B04 #075056 #233038 #FDF6E3 #F4D47C #D3DBDD
Palette::casa_natal() (9 colours): vibrant nine-colour set for larger categorical scales
#245E55 #ED773C #808BC5 #C63F3E #EAC119 #EAA7C7 #9ED6DF #1D1D1B #EAE4DA
Custom palettes
#![allow(unused)] fn main() { use kuva::render::palette::Palette; let pal = Palette::custom( "my_palette", vec!["#264653".into(), "#2a9d8f".into(), "#e9c46a".into(), "#f4a261".into(), "#e76f51".into()], ); let layout = Layout::auto_from_plots(&plots).with_palette(pal); }
API reference
| Method | Description |
|---|---|
Palette::wong() | Bang Wong 8-color colorblind-safe palette |
Palette::okabe_ito() | Alias for Wong |
Palette::tol_bright() | Paul Tol qualitative bright, 7 colors |
Palette::tol_muted() | Paul Tol qualitative muted, 10 colors |
Palette::tol_light() | Paul Tol qualitative light, 9 colors |
Palette::ibm() | IBM Design Language, 5 colors |
Palette::deuteranopia() | Alias for Wong |
Palette::protanopia() | Alias for Wong |
Palette::tritanopia() | Alias for Tol Bright |
Palette::category10() | Tableau/D3 Category10, 10 colors (default) |
Palette::pastel() | Pastel variant of Category10, 10 colors |
Palette::bold() | High-saturation vivid, 10 colors |
Palette::paloma() … Palette::casa_natal() | LTC qualitative palettes (see the LTC section above) |
Palette::custom(name, colors) | User-defined palette |
pal[i] | Color at index i; wraps with modulo |
pal.len() | Number of colors |
pal.colors() | Slice of all color strings |
pal.iter() | Cycling iterator (never returns None) |