Color in Data Visualization: Rules Scientists Actually Follow
The rainbow colormap is one of the most popular and most harmful choices in data visualization. It creates false boundaries, hides real patterns, and is illegible to 8% of men. Here are the rules that data scientists and researchers actually follow β and why.
Why Rainbow Colormaps Are Bad
The rainbow (or "jet") colormap maps data values to the hue spectrum: low values are blue, middle values are green/yellow, high values are red. It seems intuitive, but it has been thoroughly debunked by visualization researchers.
In their landmark 2007 paper "Rainbow Color Map (Still) Considered Harmful," published in IEEE Computer Graphics and Applications, David Borland and Russell Taylor II identified three critical problems:
- Perceptual non-uniformity. The human visual system is not equally sensitive to all hue transitions. The yellow-green boundary is perceived as a sharp edge even when the underlying data is smooth. This creates visual artifacts β false boundaries that do not exist in the data.
- Loss of ordering. Hue is a circular dimension without a natural ordering. Is green "higher" than blue? Is orange "between" red and yellow numerically? Our brains do not naturally order hues, making it hard to read quantitative data from a rainbow map.
- Inaccessibility. The rainbow colormap relies entirely on hue discrimination. For the approximately 300 million people with color vision deficiency, large portions of the rainbow (particularly green-yellow-red) are indistinguishable.
Research by Rogowitz and Treinish (1998) at IBM Research showed that rainbow colormaps can lead scientists to misinterpret their own data β seeing patterns, boundaries, and features that are pure artifacts of the color mapping.
Perceptually Uniform Colormaps: The Solution
In 2015, StΓ©fan van der Walt and Nathaniel Smith designed viridis, magma, plasma, and inferno as replacements for the rainbow colormap in matplotlib (Python's dominant plotting library). These colormaps were engineered to be:
- Perceptually uniform: Equal data steps produce equal visual steps across the entire range
- Monotonically increasing in lightness: From dark to light, always β so they work in grayscale
- CVD-accessible: Readable by people with all common forms of color vision deficiency
- Pretty: Because scientists are more likely to adopt tools they find aesthetically pleasing
Viridis was designed in the CIECAM02 color appearance model (an advanced version of CIE L*a*b*) and optimized for uniform lightness steps. The palette traverses blue β green β yellow, using a path through color space that maximizes perceptual distance at each step while avoiding the red-green axis (which is problematic for CVD).
ColorBrewer: The Gold Standard
ColorBrewer, created by cartography professor Cynthia Brewer at Penn State University and published as a web tool in 2002, remains the gold standard for choosing color schemes in data visualization. Brewer's palettes, published in her book Designing Better Maps (2005), are organized into three types:
Sequential Palettes
For ordered data from low to high. They progress from light to dark (or vice versa) within a single hue or a narrow hue range. Example: light blue to dark blue for population density.
Diverging Palettes
For data with a meaningful midpoint (e.g., temperature anomaly, profit/loss). Two sequential palettes meet at a neutral midpoint. The two sides should be distinguishable by people with CVD.
Qualitative Palettes
For categorical data (different groups, no order). Colors should be maximally distinguishable. No color should be perceived as more important than another (so no very dark or very light outliers).
The Rules Scientists Follow
Based on research by Healey and Enns (2012), Wong (2011), and Brewer (2005), here are the consensus guidelines for color in data visualization:
- Never use the rainbow colormap for continuous data. Use viridis, magma, or a ColorBrewer sequential palette instead.
- Limit categorical colors to 7 or fewer. Miller's Law (1956) shows humans can reliably distinguish about 7 items in working memory. Beyond 7 categories, use grouping, labels, or a different visual encoding.
- Avoid red-green as the only distinction. Use blue-orange, blue-red, or add patterns/textures. Always test with a CVD simulator.
- Ensure your colormap works in grayscale. If your plot is printed in black and white (as it often is in academic papers), the data should still be readable. Monotonically increasing lightness ensures this.
- Match the colormap to the data type. Sequential for ordered data. Diverging for data with a meaningful midpoint. Qualitative for categories. Never use a sequential palette for categories (it implies order) or a qualitative palette for continuous data (it implies boundaries).
- Consider cultural context. Red = bad/loss is a Western convention. In Chinese financial contexts, red = gain. Know your audience.
- Label directly when possible. Color legends require the viewer to look back and forth, increasing cognitive load. Direct labels on data points or inline annotations are more effective (Tufte, 1983).
Tools for Better Data Color
Several tools can help you choose better colors for data:
- ColorBrewer 2.0 (colorbrewer2.org) β the original tool by Cynthia Brewer
- Chroma.js β a JavaScript library for color manipulation that includes perceptually uniform interpolation
- d3-scale-chromatic β D3's implementation of ColorBrewer and other scientifically designed palettes
- Coolors β palette generator with CVD simulation
- Our Color Wheel β explore harmonic relationships and check contrast ratios
Conclusion
Good data visualization requires treating color as a rigorous design decision, not an afterthought. The rainbow colormap feels intuitive but creates artifacts, excludes users with CVD, and fails in grayscale. Perceptually uniform colormaps like viridis and structured palettes from ColorBrewer are designed to communicate data honestly and accessibly.
Start building accessible visualization palettes with our Color Wheel and Color Converter. Check the contrast of your palette choices, and browse our curated palette collection for inspiration. Remember: the goal of data visualization is to reveal the data, not the color palette.
Sources & References
This article is based on research from leading color authorities:
- Edward Tufte - Visual Display - Data visualization expert
- Color Brewer - Scientific color maps for data
- WCAG Accessibility - Color contrast guidelines