Data Visualization: Color and Accessibility Guide

Data Visualization: Color and Accessibility Guide

A guide to accessible data visualization — Okabe-Ito categorical, viridis sequential, redundant encoding, alt text as finding, keyboard navigation, and chart contrast.

Worldwide, about 8 percent of men have a red-green color vision deficiency, and default red-green chart palettes are hard for them to tell apart; charts that rely on color as the only signal for categorical or ordinal data leave these readers without the encoding. The fix is small in scope and high in impact — use the Okabe-Ito palette for categorical, viridis for sequential, never let color carry the encoding alone, write alt text as a one-sentence summary of the finding, and make interactive charts keyboard-navigable with live-region updates.

Color is easy to misuse in product data visualization. It is also relatively easy to fix, because established answers have been published for years, and some are built into chart libraries — viridis has been Matplotlib's default colormap since version 2.0. The patterns below cover the work that brings a chart from "looks colorful" to "readable by the audience that actually opens it."

Color blindness affects more users than you think

Red-green color vision deficiency affects about 8 percent of men and 0.5 percent of women worldwide, according to Colour Blind Awareness. Deuteranomaly is the most common form, at about 5 percent of men; protanomaly, protanopia, and deuteranopia each account for about 1 percent. Blue-yellow deficiencies (tritan types) are very rare. In a product with a few thousand active users, that translates to dozens to hundreds of people who struggle to tell apart the colors of a default red-green categorical palette.

The two diagnostic problems with chart defaults are predictable. A red bar next to a green bar is the canonical "good versus bad" coloring, and the two hues are hard to distinguish for the most common color-blindness type. A red-yellow-green traffic-light status indicator is the second canonical failure. Both have decades-old replacements that are no harder to use; library defaults are one reason they persist.

Test palettes with a simulator. Sim Daltonism on macOS, the Stark plugin in Figma, and the Chrome DevTools Rendering tab's vision-deficiency emulator all show how a palette looks under different vision conditions. The test takes seconds and can catch palette mistakes before they ship.

Colorblind-safe palettes

Chart palettes fall into three main families.

Categorical palettes encode unordered categories — product lines, regions, segments. The Okabe-Ito eight-color palette is a colorblind-safe choice that Okabe and Ito first published online in 2002 (revised in 2008). As a rule of thumb, eight categories is also a practical ceiling for a categorical chart; beyond that, even a perfect palette runs out of distinguishable colors and the chart needs a structural change rather than a palette change.

Sequential palettes encode ordered values along a single dimension — counts, percentages, density. The viridis family (viridis, plasma, magma, inferno, cividis) is perceptually uniform — equal steps in data are perceived as equal steps in color, with lightness increasing from one end of the map to the other. Viridis, plasma, magma, and inferno were also designed to be relatively friendly to common forms of color blindness. Matplotlib's documentation on perceptually uniform colormaps explains why these palettes beat the plain rainbow they replaced. The rainbow palette has non-uniform perceptual steps and can be hard to read for viewers with red-green color vision deficiencies; it should not appear in new product UI.

Diverging palettes encode values that diverge from a center — temperature anomaly, performance against benchmark, sentiment. Blue-to-red schemes with a light midpoint, such as ColorBrewer's RdBu, are marked colorblind-safe in ColorBrewer, because blue and red stay distinguishable for red-green deficiencies. The pairing to avoid is red and green at the two ends: ColorBrewer's red-yellow-green (RdYlGn) scheme is not marked colorblind-safe. Choose based on which end of the palette carries the more important signal.

Palette typeUse caseRecommended choice
CategoricalUnordered categories (regions, products)Okabe-Ito 8-color
SequentialOrdered values (counts, percentages)viridis / plasma / magma
DivergingValues diverging from a centerBlue-red with a light midpoint (ColorBrewer RdBu)

Redundant encoding

Color should never carry the encoding alone — pair it with shape, label, or pattern.

Scatter plots get color plus shape. Circles, squares, triangles, diamonds — as a rule of thumb, the geometric set covers four to five categories without exhausting recognizability. Even when the palette is colorblind-safe, shape carries the encoding in monochrome printing, low-contrast environments, and quick glances.

Line charts get color plus dash pattern. Solid, dashed, dotted, and dash-dotted handle four lines, which, as a rule of thumb, is also near the readable line count for a single chart. The dash pattern survives the chart being photocopied, projected on a low-contrast screen, or read by a viewer who has turned brightness down to save battery.

Bar charts get color plus direct labels when there is room. For two-or-three category charts, direct labels inside or above bars can replace a legend. The reader's eye does not have to round-trip to the legend, which removes one source of error and one source of cognitive load.

WCAG 1.4.1 Use of Color is explicit on this point (Level A): color is not used as the only visual means of conveying information, indicating an action, prompting a response, or distinguishing a visual element. The text of the success criterion is short, and the implementation across charts is straightforward; charts that rely on color alone are still worth checking for in production product UI.

Alt text and chart summary

A chart's alt text is the chart's voice to screen reader users and to readers who load the page with images off. Written well, it is the same one-sentence summary a sighted reader would write to a colleague. Written badly, it is a redundant description of the chart title.

The pattern recommended here is alt-text-as-finding. For example, "Revenue grew 18 percent in Q3, driven primarily by Asia-Pacific" is the headline a sighted reader would extract. The chart title is "Quarterly Revenue by Region" and does not need to be repeated. Writing the finding takes longer than writing the description, and the resulting alt text is short, useful, and aligned with what the chart was for.

For charts with structure that does not compress into one sentence, aria-describedby linking to a longer paragraph below the chart works. The paragraph names the data source, the time range, and the two or three findings worth surfacing. The longer description does not replace the alt text; the alt text still delivers the headline.

Data table fallback is the third layer. A <table> element either below the chart or in a <details> element accessible from the chart caption gives screen reader users the same access to the underlying data that sighted users have. W3C WAI's complex images tutorial explains that complex images such as charts need a two-part text alternative — a short description plus a long description — and shows ways to provide the long description, including one that puts a data table in the figure caption.

Interactive chart accessibility

Charts that the user can hover, click, or filter need keyboard navigation and screen reader announcements, not just mouse handlers.

The WAI-ARIA Authoring Practices Guide has no dedicated chart pattern, so keyboard conventions vary between libraries. A common approach uses arrow keys: left and right move between adjacent points; up and down move between series in multi-series charts. The focused point is visible — a ring, a larger size, a high-contrast highlight — and the focus stays visible when the user tabs away and tabs back.

Live region announcements convey the focused value to screen readers. An aria-live="polite" region near the chart updates as the user navigates — for example, "Q3 2024, revenue four point two million dollars." The user hears the focused value without having to interpret a visual chart. Without the live region or an accessible name on each focusable point, the chart can be silent to assistive technology however clear the visual focus indicator looks.

Focus must not get trapped inside the chart. The user can enter the chart with Tab, navigate inside with arrow keys, and leave with Tab again. Trapping focus is a common bug in custom chart libraries; the fix is to handle Tab inside the chart as "leave the chart" rather than "next data point."

The interactive accessibility patterns above sit downstream of broader accessibility work — the topic on WCAG accessibility covers the conformance levels and audit procedures in the depth product UX articles cannot.

Contrast and chart elements

Text inside a chart is text, and it follows the same contrast rules as any other text in the product.

Under WCAG 2.2 Success Criterion 1.4.3 Contrast (Minimum) (Level AA), axis labels, tick labels, legend text, and tooltip text need a contrast ratio of at least 4.5:1 against their background — the same baseline as body copy. The criterion's exceptions apply here too: large-scale text and images of large-scale text need at least 3:1, and text or images of text that are part of an inactive user interface component, that are pure decoration, that are not visible to anyone, or that are part of a picture that contains significant other visual content have no contrast requirement, nor does text that is part of a logo or brand name. One failure to watch for is light gray labels on a white background; they look elegant in a design comp and become unreadable on a real screen.

Gridlines sit at lower contrast than data. WCAG states a contrast ratio rather than an opacity value, and it sets a contrast floor for graphics: WCAG 1.4.11 Non-text Contrast (Level AA) asks for a contrast ratio of at least 3:1 against adjacent colors for parts of graphics required to understand the content, such as a chart's lines and bars, except when a particular presentation of graphics is essential to the information being conveyed. W3C's Understanding document for 1.4.11 counts gridlines that readers need to read off values among those parts: in its line-chart example, the gray lines marking value increments and the colored data lines should have 3:1 contrast against their background, and because they barely overlap, the data lines do not need to contrast with each other or with the gray value lines. The same document notes that the requirement does not apply when text labels or values on the chart convey the same information, when the graphic is purely aesthetic, or when the information is available in another form, such as a table that follows the graph. Tune gridlines to meet that floor without competing with the data marks: gridlines that are too dark turn the chart into a graph-paper texture; gridlines that are too light disappear and the reader cannot read off values.

Hover tooltips appear over the chart and need their own contrast check. The tooltip text falls under 1.4.3 against the tooltip background, and the indicator line connecting the tooltip to the data point falls under 1.4.11 against what sits behind it when readers need the line to find the data point. Keeping the tooltip background distinct from the chart behind it is a design choice that helps legibility. Tooltips that float over dark and light areas of the chart need a backdrop or a fixed-position pattern that keeps contrast consistent.

A small additional check: desaturate the chart to grayscale and confirm the categories are still distinguishable. If the grayscale chart fails, the color chart relies on hue alone, and the redundant encoding above is missing.

Companion pieces on this topic cover the rest of the data-visualization surface: chart type selection decision tree for the chart-family choice and dashboard and KPI card patterns for the multi-chart context. The main guide on web UX design patterns maps how data visualization sits alongside the other five UX pattern families.

The work above is small in scope and high in leverage. Switching a default palette and adding a one-sentence alt text takes minutes per chart. Doing it across a product extends those improvements to every chart readers open.

Project Inquiry