Colorblind-friendly palettes for charts
Palettes made to stay readable for people with color blindness, with hex codes ready for matplotlib, ggplot2, CSS and JSON, and what our own checker finds in each. Below them, paste your own chart colors to see which pairs merge for color-blind viewers.
Pick a palette
Our check (every pair of colors): #E69F00 and #CC79A7 are close for tritanopia (ΔE 7.9).
- #000000
- #E69F00
- #56B4E9
- #009E73
- #F0E442
- #0072B2
- #D55E00
- #CC79A7
| Python / matplotlib | colors = ['#000000', '#E69F00', '#56B4E9', '#009E73', '#F0E442', '#0072B2', '#D55E00', '#CC79A7'] | |
|---|---|---|
| R / ggplot2 | scale_colour_manual(values = c("#000000", "#E69F00", "#56B4E9", "#009E73", "#F0E442", "#0072B2", "#D55E00", "#CC79A7")) | |
| CSS | --chart-1: #000000;
--chart-2: #E69F00;
--chart-3: #56B4E9;
--chart-4: #009E73;
--chart-5: #F0E442;
--chart-6: #0072B2;
--chart-7: #D55E00;
--chart-8: #CC79A7; | |
| JSON | ["#000000","#E69F00","#56B4E9","#009E73","#F0E442","#0072B2","#D55E00","#CC79A7"] |
Paste 2 to 12 colors in any format, separated by commas or lines. A list copied from Python or R code works too, including matplotlib names such as tab:red or xkcd:sky blue.
Typical vision: closest pair ΔE 22.2 — clear
Protanopia: closest pair ΔE 17.7 — clear
Deuteranopia: closest pair ΔE 12.7 — clear
Tritanopia: closest pair ΔE 10.5 — clear
Our rule, not a standard: ΔE2000 under 6 is too close (the same color family), under 10 is easy to mix up in a small legend. The simulation models people who lack one cone type; milder color weakness varies from person to person, so label lines and bars as well.
Why the default colors fail
matplotlib’s default red and green, tab:red #D62728 and tab:green #2CA02C, differ by ΔE 71.8 for typical vision, but only 4.7 once simulated for deuteranopia, a red-green type of color blindness: the same color family. Paste them into the checker above to see it. Charts that tell red from green by color alone lose that information for these readers.
Where the palettes come from
Every value is copied from the original source, not from a blog post. Okabe–Ito is the eight-color set from Masataka Okabe and Kei Ito’s «Color Universal Design» page, read from its RGB column. viridis is matplotlib’s 256-step table by Nathaniel Smith, Stéfan van der Walt and Eric Firing, released into the public domain (CC0); n colors are picked as matplotlib picks them. ColorBrewer schemes are listed only at the sizes ColorBrewer itself marks as colorblind-safe. Our checker does not agree at every size: the line under each palette says what it finds.
This product includes color specifications and designs developed by Cynthia Brewer (http://colorbrewer.org/). ColorBrewer is distributed under the Apache License 2.0.
The checker uses the same simulation as the color blindness simulator: Viénot, Brettel and Mollon (1999) for protanopia and deuteranopia, Brettel, Viénot and Mollon (1997) for tritanopia. The difference between two colors is CIEDE2000, as in the Delta E calculator.
Colorblind-safe palettes: questions
- What is the best colorblind-friendly palette for charts?
- For categories, the Okabe–Ito palette of eight colors (often called the Wong palette, after Bang Wong’s 2011 Nature Methods column «Points of view: Color blindness», which recommended it) is the usual choice: it was designed to stay distinct for people with red-green color blindness and is printable. Our checker flags orange and reddish purple: they come out close under tritanopia (ΔE 7.9), so label them in a legend. For ordered values, viridis runs from dark purple to yellow and keeps rising in lightness, so it reads even in greyscale.
- What are the Okabe–Ito hex codes?
- black #000000, orange #E69F00, sky blue #56B4E9, bluish green #009E73, yellow #F0E442, blue #0072B2, vermilion #D55E00, reddish purple #CC79A7. They come from the RGB values in Okabe and Ito’s Color Universal Design page.
- How do I use viridis in matplotlib or ggplot2?
- In matplotlib, cmap="viridis" for a continuous scale, or plt.cm.viridis(np.linspace(0, 1, n)) for n separate colors; the hex lists on this page are exactly those n colors. In ggplot2, scale_colour_viridis_d() and scale_fill_viridis_c() give the viridis scale; to fix exact colors, paste the list from this page into scale_colour_manual().
- How does the checker decide that two colors are too close?
- It simulates each color for protanopia, deuteranopia and tritanopia, then measures the colors with CIEDE2000, the color difference formula. For categories it measures every pair: under 6 the two look like the same color family; under 10 they are easy to mix up in a small legend. For a sequential or diverging scale, neighbouring steps are meant to be similar, so it measures only neighbouring steps, with a limit of 3, and checks that lightness keeps its order in every view; on a diverging scale the two steps at the same distance from the middle must also differ by 6 or more. These thresholds are our rule, not a standard.
- Is a palette that passes the check safe for everyone?
- No. The simulation models people who lack one type of cone. Many color-blind people have a weaker cone instead, and how much it shifts colors varies. Labels on lines, patterns on bars and differences in lightness help everyone.
Sources
- Okabe M., Ito K. (2002, updated 2008). Color Universal Design (CUD): how to make figures and presentations that are friendly to colorblind people. Fig. 16, colorblind barrier-free color palette, RGB values 0–255. Link
- matplotlib, lib/matplotlib/_cm_listed.py: the viridis colormap data (256 entries), CC0. Link
- BIDS/colormap, colormaps.py: «New matplotlib colormaps by Nathaniel J. Smith, Stefan van der Walt, and (in the case of viridis) Eric Firing», released under CC0. Link
- Brewer C. A., Axis Maps. ColorBrewer 2.0: colorbrewer_schemes.js with each scheme’s colorblind-safe flag, Apache License 2.0. Link
- Viénot F., Brettel H., Mollon J. D. (1999). Digital video colourmaps for checking the legibility of displays by dichromats. Color Research & Application 24(4), 243–252. DOI
- Brettel H., Viénot F., Mollon J. D. (1997). Computerized simulation of color appearance for dichromats. Journal of the Optical Society of America A 14(10), 2647–2655. DOI
- Sharma G., Wu W., Dalal E. N. (2005). The CIEDE2000 color-difference formula: implementation notes, supplementary test data, and mathematical observations. Color Research & Application 30(1), 21–30. DOI