Choosing a Color Palette for Data Visualization

⏱️ 35 sec read 📊 Visualization

The right color palette is determined by your data type, not your taste. Ordered numeric data wants a sequential palette, data with a meaningful midpoint wants diverging, and unordered groups want categorical. Pick the wrong family and the chart will mislead even if the colors are pretty.

The Three Palette Families

When to Use a Sequential Palette

Use sequential when the values have a natural order and no special midpoint:

Battle-tested palettes:

When to Use a Diverging Palette

Use diverging when zero (or a target, or an average) is meaningful:

Battle-tested palettes: RdBu, BrBG, PiYG, RdYlGn (avoid for colorblind audiences — see below).

Always center the color scale on the meaningful midpoint. A diverging palette with a midpoint at the data mean (instead of zero) hides the sign of the values.

When to Use a Categorical Palette

Use categorical for nominal data — groups with no order:

Battle-tested palettes: Tableau 10, Set2, Dark2, Okabe-Ito (8-color colorblind-safe).

Cap your categorical palette at 7 colors. Beyond that, the eye can't distinguish them and the legend becomes a lookup chore — group small categories into "Other."

Decision Rule in One Sentence

Is your data ordered?
├─ No  → Categorical palette (Tableau 10, Set2)
└─ Yes → Is there a meaningful midpoint?
         ├─ No  → Sequential palette (Viridis, Blues)
         └─ Yes → Diverging palette (RdBu, BrBG)

Accessibility: Skip Red-Green Diverging

Roughly 8% of men and 0.5% of women have red-green color deficiency. RdYlGn and other red-green diverging palettes look identical to those viewers. Safer alternatives:

Test your chart with a simulator like Coblis before publishing.

Code: Picking a Palette in Python

import seaborn as sns

# Sequential
sns.color_palette("viridis", as_cmap=True)
sns.color_palette("Blues", n_colors=5)

# Diverging
sns.color_palette("RdBu_r", as_cmap=True)  # _r reverses

# Categorical
sns.color_palette("tab10")        # Tableau 10
sns.color_palette("colorblind")   # Okabe-Ito-style

Common Pitfalls

Pro Tip: ColorBrewer filters palettes by data type and accessibility constraints in one click. It's the fastest way to get from "I have ordinal data" to "here's a palette that works."

← Back to Visualization Tips