Choosing a Color Palette for Data 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
- Sequential — light to dark in a single hue. For ordered values (counts, percentages, time).
- Diverging — two hues meeting at a neutral midpoint. For values around a meaningful zero (profit/loss, above/below average).
- Categorical — distinct hues, similar lightness. For unordered groups (countries, product types).
When to Use a Sequential Palette
Use sequential when the values have a natural order and no special midpoint:
- Population density on a choropleth
- Count of orders per region
- Heatmap of correlation magnitudes (0 to 1)
Battle-tested palettes:
Viridis,Plasma,Inferno,Magma(matplotlib, perceptually uniform, colorblind-safe)Blues,Greens,YlOrRd(ColorBrewer)- Tableau's Blue or Orange sequential ramps
When to Use a Diverging Palette
Use diverging when zero (or a target, or an average) is meaningful:
- Profit vs loss
- Sentiment scores (-1 to +1)
- Year-over-year change
- Correlation matrices that include negatives (-1 to +1)
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:
- Product categories
- Countries on a multi-line chart
- Cluster labels from k-means
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:
- Diverging:
RdBu(red-blue),BrBG(brown-teal),PuOr(purple-orange) - Sequential:
Viridisfamily — designed to be both perceptually uniform and colorblind-safe - Categorical:
Okabe-Ito— 8 colors verified for protanopia, deuteranopia, and tritanopia
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
- Rainbow palettes (jet): not perceptually uniform — they create false boundaries in the data. Use Viridis instead.
- Categorical for ordered data: using Tableau 10 for "small / medium / large" throws away the order information.
- Diverging on data without a midpoint: if your range is 0–100 with no special middle, the palette implies a meaning that isn't there.
- Too many categorical colors: more than 7 distinct hues is a legend, not a chart.
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