Colorblind-safe chart palettes for light and dark mode
Charts that rely on red against green fail for readers with color vision deficiency. This post covers palettes that work in light and dark mode.
Made with OpenChart. How to build this line chart
Roughly 1 in 12 men of Northern European descent has red-green color vision deficiency, which collapses red and green hues into similar yellow-brown tones. Any chart that relies on a red-green pair for positive and negative bars or two competing lines erases that distinction for those readers. Converting a draft chart to grayscale catches most palette failures immediately, because two colors that differ only in hue flatten into the same shade of gray.
Luminance, the perceived brightness of a color, is the channel that survives both color vision deficiency and monochrome printing. Deuteranopia (reduced green sensitivity) and protanopia (reduced red sensitivity) distort how hues look while leaving brightness differences intact. Building a palette around lightness contrast first, then picking hues that stay apart under both conditions, gives every reader the same visual order.
Highlighting two series
Assigning six bright hues to six lines forces readers to jump back and forth between the plot and a legend while trying to tell medium green apart from orange or teal. Even with full color vision, most people hold only three or four distinct hues in working memory at once. When a chart centers on one comparison, giving every line equal visual weight hides the main change behind four competing colors.
Focusing two lines in high-contrast hues and muting the rest to neutral gray makes the comparison legible in color and in grayscale. Gas and coal drove the main shift in US electricity generation from 2016 to 2023, so gas takes deep blue and coal takes vermilion from the Okabe-Ito colorblind-safe palette. That blue-orange pair stays distinct across red-green and blue-yellow deficiencies, and thicker strokes separate both lines from the four muted gray sources.
Direct endpoint labels place each source name right beside its line and remove the legend altogether. Readers can identify every series without matching a colored swatch to a stroke, even where hydro and solar finish tied at 5.8% in 2023.
Made with OpenChart. How to build this line chart
Sequential scales and dark mode
Ordered numeric data, such as state unemployment rates, needs a sequential scale that steps steadily from light to dark within one hue. Rainbow scales break that order because yellow looks brighter than neighboring green and blue and creates false bands across smooth data. A single-hue blue ramp maps low values to pale tints and high values to deep shades, so every reader sees the same ranking in color or grayscale.
Dark mode changes how every palette reads because dark surfaces make saturated colors glare and swallow dark strokes. Blindly inverting raw hex codes turns muted shades into harsh neons and breaks text contrast on filled tiles. Well-tuned dark themes lift categorical colors to higher lightness against dark backgrounds and reverse sequential ramps so high values glow brightest while tile labels switch ink for contrast.
Across US states and DC in the Bureau of Labor Statistics snapshot, unemployment runs from 2.3% in South Dakota to 5.7% in DC. Switching between light and dark mode preserves that single-hue order while adapting both the ramp direction and the label contrast inside every tile.
Made with OpenChart. How to build this tile map
The spec
Code under the electricity chart opens its spec. In encoding.color, scale.domain lists all six sources in a fixed order so scale.range assigns deep blue (#0072b2) to Gas, vermilion (#d55e00) to Coal, and neutral gray (#7a858f) to the remaining four. seriesStyles raises the focus stroke width to three pixels, while legend: { show: false } and endpointLabels: { content: "label" } place each series name at the end of its line.
On a phone, the compact and medium blocks in overrides (charts under 700 pixels wide) set the x axis ticks to 2016, 2020 and 2023, so the first and last years still show beside the labels.
On the tile map, palette: "blue" picks OpenChart’s sequential ramp, which adjusts automatically when the host passes darkMode: "force" or darkMode: "auto". When a chart must hit exact brand colors in both themes, any slot in theme.colors (including each entry in theme.colors.categorical) accepts a { light, dark } object instead of one string. Supplying a darker shade for light and a lifted shade for dark locks contrast on both backgrounds while bypassing automatic derivation.
For built-in color schemes and grayscale print patterns, see the color palettes guide.