30

Color in Data Visualization

In a chart, color is not decoration - it is data. A map of temperature, a heatmap of activity, a set of plotted categories: each turns numbers into hue and lightness, and a careless choice of colormap can invent patterns that are not there or hide the ones that are. This is the interactive guide to encoding data with color honestly: the three scale types, why the rainbow misleads, and how to stay readable for every viewer.

Design · 25 5 Live Demos ~40 min read Colormaps
3
Color scale types
~8%
Men with color-vision deficiency
≤ 8
Safe categorical colors
0
False boundaries in a good map
00

Advanced visual encoding lab

The hard part of data visualization is not choosing a pretty palette; it is matching color to the structure of the data. This lab turns the whole decision into one instrument: task, scale type, baseline, binning, CVD simulation, outliers, opacity, legend design, and redundant labels all update the same chart and diagnostics.

Interactive 05 - Advanced encoding lab

Stress-test a colormap before it reaches a chart

A good visualization survives grayscale, color-vision deficiency, compression, noise, and real legends. Adjust the controls and watch the canvas report where the chart starts to lie: false boundaries, misplaced midpoint, weak category separation, missing redundancy, or an outlier that steals the entire dynamic range.

Encoding choice

Calculating...

Legend contract

Calculating...

Accessibility diagnosis

Calculating...

Export tokens

Calculating...

Perceptual order

lightness monotonicity0%

False boundary risk

lower is better0%

CVD resilience

separability after simulation0%

Legend clarity

mapping contract0%

Category separation

minimum color distance0%

Honesty score

overall risk0%

01

Why color is data, not decor

The earlier articles in this library treated color as something to measure or to compose with. In data visualization it does a third job: it carries information. When a value is mapped to a color through a colormap (also called a color scale or palette), the reader runs that mapping in reverse to recover the data. If the mapping is ambiguous or uneven, the reader recovers the wrong numbers - and unlike a mislabeled axis, a bad colormap fails silently.

Two failures dominate. The first is using the wrong type of scale for the data - a rainbow for ordered magnitudes, or a sequential ramp for categories. The second is using a scale that is not perceptually uniform, so equal steps in the data do not look like equal steps in color. Both are avoidable with a little theory, and the demos here let you see each failure happen and then fix it.

The core principle: the structure of your color scale must match the structure of your data. Ordered data needs an ordered scale; data with a meaningful center needs a scale with a center; unordered groups need unordered, equally-weighted colors. Get this match right and most other choices become easy.
02

The three scale types

Almost every honest colormap is one of three kinds. Choosing the right one is the single most consequential decision in coloring a chart.

Scale Use when data is… How it looks Example
Sequential Ordered low → high, one direction One hue, lightness ramps monotonically Population density, temperature, counts
Diverging Ordered around a meaningful midpoint Two hues meeting at a neutral center Profit vs loss, anomaly vs average, ±change
Categorical Unordered groups / labels Distinct hues, similar lightness Countries, product lines, teams
Interactive 01 · Scale explorer

Map the same field through different scales

Below is one continuous data field rendered as a heatmap. Switch the colormap and watch how the same numbers tell different stories. A sequential map reads as smooth magnitude; a diverging map splits it around the middle; grayscale shows the raw ordering with no hue at all. The legend underneath is the key the reader uses to decode it.

sequential magnitude
lowmidhigh
03

Sequential scales

A sequential scale encodes data that runs from low to high in one direction: counts, density, magnitude, probability. The key property is that lightness must move monotonically - steadily darker or steadily lighter - because lightness is the channel the eye reads as "more." Hue may shift along the way (viridis travels purple → blue → green → yellow), but it is the relentless lightness ramp that makes the order legible, even in grayscale or for a colorblind viewer.

The classic mistake is a sequential scale whose lightness is not monotonic, so two different values map to the same apparent brightness and become indistinguishable. The good modern defaults - viridis, magma, cividis - are engineered specifically to keep lightness rising at a near-constant rate.

Quick test: screenshot your sequential chart and desaturate it to grayscale. If the order is still perfectly readable as light-to-dark, your scale is sound. If bands blur together, the lightness ramp is broken - switch to viridis or a single-hue ramp.
04

Diverging scales

A diverging scale is for data with a meaningful midpoint - zero, an average, a target, a baseline. It uses two contrasting hues (classically blue and red) that grow more saturated and darker as values move away from a neutral, light center. The center is the anchor: it must sit on the value that actually matters, or the chart lies.

Interactive 02 · The midpoint matters

Move the neutral point and watch the story change

Each cell is a region's change versus a baseline, colored on a blue-white-red diverging scale. Drag the midpoint: where you place the neutral white decides which regions read as "good" (blue) and which as "bad" (red). Putting the midpoint anywhere but the true reference value manufactures a conclusion - the most common diverging-scale abuse.

midpoint at the true baseline — honest
−50 (red)0+50 (blue)
05

Categorical scales

A categorical (qualitative) scale encodes unordered groups, so its colors must look equally weighted - distinct in hue but similar in lightness and saturation, so none jumps out as "more important" or "higher." The hard limit is how many colors a reader can reliably tell apart: beyond roughly eight, distinct hues start to collide and the legend becomes a memory test. Past that, switch to direct labels, grouping, or small multiples instead of more colors.

Equal weight
Hold lightness and saturation roughly constant so no category looks dominant. Order is not part of the data, so it must not appear in the color.
Eight or fewer
Working memory and hue discrimination both cap out around 7-8 categories. More colors means more confusion, not more clarity.
Reserve a hue
Keep one strong color (often red) for "highlight" or "other" rather than spending it on an ordinary category.
Safe by design
Prefer a palette built for color-vision deficiency, such as Okabe-Ito, instead of an arbitrary set of bright hues.
06

The rainbow problem

For decades the default heatmap colormap was jet - the rainbow from blue through cyan, green, and yellow to red. It looks vivid and "scientific," and it is one of the most criticized choices in all of visualization. Jet is not perceptually uniform: its lightness rises and falls instead of climbing steadily, so it has bright ridges at cyan and yellow and dark valleys at blue and red. Those ridges read as edges - boundaries the data never contained - while the dark ends crush real detail.

Interactive 03 · Jet vs viridis

The same data in a bad map and a good one

Both panels show the identical continuous field - left in jet, right in viridis. Now press Show lightness only: each map is replaced by the brightness the eye actually perceives. Viridis becomes a smooth ramp (its lightness is monotonic), while jet turns into lumpy bands - proof that it invents light/dark structure the data does not have. That is exactly what misleads a reader.

Jet (rainbow)

Bright ridges at cyan/yellow = false boundaries

Viridis (perceptual)

Monotonic lightness = honest magnitude

Why it matters beyond aesthetics: jet has caused real misreadings in medical imaging and science, where the false cyan/yellow edges were mistaken for genuine structure. Unless you have a specific reason, never ship a rainbow colormap for continuous data - reach for viridis, magma, cividis, or a single-hue sequential scale.
07

Colorblind-safe palettes

Around 8% of men and 0.5% of women have a color-vision deficiency, most commonly red-green. A categorical palette that relies on telling red from green - or any two hues that collapse together under CVD - excludes a large slice of your audience. The fix is to choose colors that stay distinct after simulation and to lean on lightness differences, which survive every type of CVD.

Interactive 04 · Colorblind check

Simulate CVD and see which series collide

Pick a categorical palette, then simulate a color-vision deficiency. The swatches re-render as that viewer would see them, and the checker flags any two series that become too similar to distinguish. Compare the generic bright palette with the Okabe-Ito set, which was designed to stay separable under all common deficiencies.

All series remain distinguishable.
08

Legends and redundant encoding

A colormap is only half a chart; the legend is the other half - the key that turns colors back into numbers. A continuous scale needs a continuous color bar with labeled values; a categorical scale needs an unambiguous swatch-to-label mapping, ideally placed near or directly on the marks it describes. A beautiful colormap with a missing or mislabeled legend is unreadable.

The most robust safeguard is redundant encoding: never let color be the only carrier of meaning. Pair it with direct labels, shapes, line styles, position, or text. If your chart still works when printed in grayscale or seen by a colorblind reader, color has become an enhancement rather than a single point of failure - which is exactly where you want it.

"If the information disappears the moment the color does, the color was never decoration - it was the only label you had. Add a second one." Editorial summary · encoding data with color
09

Practical guidelines

1 · Match scale to data
Ordered → sequential. Has a meaningful center → diverging. Unordered groups → categorical. Decide this before picking colors.
2 · Default to perceptual
Use viridis / magma / cividis for continuous data. Avoid jet and other rainbows unless you have a specific, justified reason.
3 · Anchor diverging honestly
Put the neutral midpoint on the true reference value - zero, the mean, the target - never where it flatters the story.
4 · Cap categories
Eight colors or fewer, equal weight, from a CVD-safe set. Beyond that, group, label directly, or use small multiples.
5 · Test desaturated + CVD
If it survives grayscale and a protan/deutan/tritan simulation, it will work for nearly everyone.
6 · Encode redundantly
Back color with labels, shapes, or position so meaning never rests on hue alone.
Shortcut with the tools: the Auric Artisan Palette, Shade, and Gradient libraries generate perceptual ramps in OKLCH and report WCAG contrast and CVD previews, so you can build sequential, diverging, and categorical scales that already pass these tests - then export them as design tokens.
10

From theory to code

In practice a colormap is a function from a normalized value in [0, 1] to a color. You normalize the data to that range, then look the value up in the scale - either by interpolating between a handful of control colors or by indexing a precomputed table. The crucial detail is where you interpolate: blending two colors in raw sRGB often passes through a muddy or dark middle, so good libraries interpolate in a perceptual space such as Oklch or Lab, which keeps the ramp smooth and the lightness honest.

Modern toolchains make this routine: charting libraries ship viridis and ColorBrewer scales built in, and CSS now interpolates gradients in perceptual spaces with in oklch. The takeaway is the same in every environment - normalize, map through a perceptual scale, and label the result with a legend.

11

Pitfalls and gotchas

Rainbow for magnitude
Jet's non-monotonic lightness fabricates edges and hides detail. Use a perceptual sequential map instead.
Diverging with no center
A blue-red scale on data without a real midpoint splits it arbitrarily. Use sequential unless a center is meaningful.
Too many categories
Twelve "distinct" hues are not distinct. Cap at ~8, then group or label directly.
Red-green only
The most common CVD collapses red and green. Never make them the sole distinction between two series.
Color without a legend
An unlabeled color bar is a cipher. Always provide and label the key, with real values.
Skewed normalization
Mapping a few outliers across the whole scale flattens the rest. Clip, bin, or use a robust range so the bulk of the data spans the colors.
12

Test your understanding

Six questions on scale types, perceptual uniformity, and accessibility. Instant feedback, no scores recorded - a wrong answer comes with a short explanation.

Quick check

Loading…
 
Question 1 of 6
13

Continue your journey

Data-visualization color draws on the palette-building, accessibility, and perceptual articles around it. The numbers reflect each article's position in the editorial roadmap.