Blog · Data · · 3 min read
OKLCH palettes that survive washout
Most data visualizations pick colors by eye on a clean white slide, or grab a stock rainbow or Viridis ramp and call it accessible. Neither approach holds up on a tree of life.
In Ptree, color is the visualization itself, not decoration. Every tile puts black text directly on top of its data fill. Parent clades display proportional bands of their descendants' categories, and sparse clades wash toward white so that low coverage reads immediately as uncertain. On top of that, the viewer switches between light and dark themes. A palette that looks fine as eight solid swatches in isolation falls apart once you put black text over it, wash it down to 15% coverage, and show it to a visitor with red-green color blindness.
One canonical data plane in both themes
Every categorical bucket and numeric ramp stop in Ptree's shared palette stylesheet keeps one canonical OKLCH color across both light and dark mode. Switching Ptree to dark mode updates the page ground, chrome, dividers, and secondary text, while leaving the measured data plane unchanged. Unknown stays white, data fills keep their authored colors, and tile labels stay black.
That single rule keeps the visual grammar consistent. A reader does not have to re-learn what "predatory" or "20 °C" looks like when their operating system switches to dark mode at sunset. Selection and hover states never override the data fill either; they show up strictly through borders, outlines, and stroke weight.
Designing against the worst pair, not the average
Ptree authors palettes in OKLCH, using Display-P3 where the wider gamut genuinely improves separation while auditing how each color degrades when reduced to sRGB at constant lightness and hue. Every candidate palette goes through the /colors/ calibration workbench under four hard constraints:
- Every canonical swatch and every washed shade along the coverage curve must clear WCAG 2.2 AA 4.5:1 contrast under
#000text. That sets a firm lightness floor on every fill in the app, so dark blues and deep purples never swallow species names. - Average separation across a palette is a vanity metric, because two indistinguishable bins ruin an overlay even when the other seven sit far apart. Calibration optimizes the worst pair's CIEDE2000 distance under both normal vision and mild deuteranomaly.
- Sparse clades wash toward white along
retained(c) = 1.03c / (c + 0.03). The workbench compares every washed category against every other category at the same wash and against every other category at full strength. That catches a common failure in choropleths and tree maps, where a poorly covered red or blue washes into a tint that resembles a well-covered yellow or cyan. - Unconstrained color optimizers always jump to fluorescent magenta and electric lime because high chroma maximizes mathematical distance. Ptree caps chroma and prefers mineral, earthen, botanical, and marine hue families. Ocean and coast share blues, freshwater and wetland move through teal and marsh green, and Growth form uses a muted tree brown that reads more cleanly than a loud red.
- all stationaryleading 100%
- almost all stationaryleading 92%, next 8%
- mostly stationaryleading 60%, next 40%
- most often stationaryleading 46%, next 20%
- variedleading 40%, next 35%
Sequential ramps as journeys, not light-to-dark tinting
A single hue scaled from pale to dark runs out of readable steps quickly and collides with Ptree's own coverage wash toward white. Instead, numeric ramps move through meaningful hue journeys: ice to water to abyss for temperature and depth, leaf to wood to earth, and fresh green through marine blue to salt-lake pink (the color of Dunaliella and halobacteria) for salinity. Ptree also separates the stops (the perceptual journey) from the stop positions, spending the color range where actual species occur.
Every tile paints from one fixed OKLCH linear-gradient over registered --band-N <color> and --seg-N <length-percentage>+ slots that are generated at build time. Unused slots repeat the final color at 100% 100%. When you switch from a 9-category property to a 3-category property, or toggle fossils on and off, the browser interpolates every band natively in OKLCH without JavaScript rebuilding gradients.
The calibration workbench proposes candidates, never final answers. Every palette gets opened on the real tree, across mixed clades and under both page themes, before a single OKLCH value enters production.