Appendix B: Color Reference

This appendix provides a quick-reference guide to the most commonly used color palettes in Python visualization. Use it to choose palettes by type, look up hex codes, and ensure your charts are accessible.


Palette Categories

Before reaching for a palette, identify the data type you are encoding:

Data Type Palette Category When to Use
Ordered numeric (temperature, revenue) Sequential Values go from low to high
Numeric with a meaningful midpoint (profit/loss, deviation from mean) Diverging Values diverge from a center
Unordered categories (region, product line) Qualitative Distinct groups, no inherent order

Mismatching palette category to data type is one of the most common visualization mistakes. A sequential palette on categorical data implies an ordering that does not exist; a qualitative palette on continuous data obscures magnitude differences.


Sequential Palettes

Viridis Family (Perceptually Uniform)

These palettes are designed to be perceptually uniform, meaning equal steps in data produce equal perceived steps in color. They also reproduce well in grayscale and are safe for most forms of color vision deficiency.

viridis (default matplotlib colormap) #440154 #482878 #3E4A89 #31688E #26838E #1F9E89 #6CCA5A #B5DE2B #FDE725

plasma #0D0887 #4B03A1 #7D03A8 #A82296 #CB4679 #E8685D #F89441 #FDC328 #F0F921

inferno #000004 #1B0C41 #4A0C6B #781C6D #A52C60 #CF4446 #ED6925 #FB9B06 #FCFFA4

magma #000004 #180F3E #451077 #721F81 #9E2F7F #CD4071 #F1605D #FD9567 #FBFDBF

cividis (optimized for deuteranopia) #002051 #0A326A #2B446E #4D566D #6B6B6F #898275 #A89A70 #C9B464 #FDEA45

Using in Code

import matplotlib.pyplot as plt

plt.imshow(data, cmap="viridis")       # Any name above works
plt.imshow(data, cmap="viridis_r")     # Append _r to reverse

Diverging Palettes

Use diverging palettes when your data has a meaningful center point (zero, average, baseline).

coolwarm #3B4CC0 #6788EE #9ABAFF #C9D7EF #EDDBD1 #F0A98B #E36B51 #B40426

RdBu (Red-Blue) #67001F #B2182B #D6604D #F4A582 #F7F7F7 #92C5DE #4393C3 #2166AC #053061

RdYlGn (Red-Yellow-Green) #A50026 #D73027 #F46D43 #FDAE61 #FFFFBF #A6D96A #66BD63 #1A9850 #006837

PiYG (Pink-Yellow-Green) #8E0152 #C51B7D #DE77AE #F1B6DA #F7F7F7 #B8E186 #7FBC41 #4D9221 #276419

Using in Code

import seaborn as sns

sns.heatmap(correlation_matrix, cmap="RdBu_r", center=0)

Qualitative Palettes

Each color is maximally distinct. Do not use more colors than the palette provides -- if you have more categories than colors, consider grouping minor categories into "Other."

Set1 (9 colors, bold) #E41A1C #377EB8 #4DAF4A #984EA3 #FF7F00 #FFFF33 #A65628 #F781BF #999999

Set2 (8 colors, muted) #66C2A5 #FC8D62 #8DA0CB #E78AC3 #A6D854 #FFD92F #E5C494 #B3B3B3

Dark2 (8 colors, saturated) #1B9E77 #D95F02 #7570B3 #E7298A #66A61E #E6AB02 #A6761D #666666

Pastel1 (9 colors, light) #FBB4AE #B3CDE3 #CCEBC5 #DECBE4 #FED9A6 #FFFFCC #E5D8BD #FDDAEC #F2F2F2

tab10 (10 colors, matplotlib default cycle) #1F77B4 #FF7F0E #2CA02C #D62728 #9467BD #8C564B #E377C2 #7F7F7F #BCBD22 #17BECF

tab20 (20 colors, paired light/dark) #1F77B4 #AEC7E8 #FF7F0E #FFBB78 #2CA02C #98DF8A #D62728 #FF9896 #9467BD #C5B0D5 #8C564B #C49C94 #E377C2 #F7B6D2 #7F7F7F #C7C7C7 #BCBD22 #DBDB8D #17BECF #9EDAE5


Colorblind-Safe Palette: Wong (2011)

Bang Wong's palette from Nature Methods is widely used in scientific publishing. It is safe for all common forms of color vision deficiency.

Name Hex RGB
Black #000000 (0, 0, 0)
Orange #E69F00 (230, 159, 0)
Sky Blue #56B4E9 (86, 180, 233)
Bluish Green #009E73 (0, 158, 115)
Yellow #F0E442 (240, 228, 66)
Blue #0072B2 (0, 114, 178)
Vermillion #D55E00 (213, 94, 0)
Reddish Purple #CC79A7 (204, 121, 167)

Using the Wong Palette in matplotlib

wong = ["#000000", "#E69F00", "#56B4E9", "#009E73",
        "#F0E442", "#0072B2", "#D55E00", "#CC79A7"]
plt.rcParams["axes.prop_cycle"] = plt.cycler(color=wong)

Palette Selection Checklist

  1. Identify the data type. Sequential, diverging, or qualitative?
  2. Count your categories. If qualitative, keep to 7 or fewer distinct colors when possible.
  3. Test for accessibility. Use a simulator (Coblis, Color Oracle) or stick to palettes marked colorblind-safe.
  4. Check in grayscale. Print a grayscale version. If categories merge, add texture or direct labels.
  5. Respect cultural conventions. Red often implies danger or loss; green implies growth. Use these associations deliberately.

ColorBrewer Reference

ColorBrewer (colorbrewer2.org) provides palettes designed for cartography that work well in all visualization contexts. Every ColorBrewer palette is available in matplotlib and seaborn by name:

cmap = plt.get_cmap("BrBG")       # Diverging: Brown-Blue-Green
cmap = plt.get_cmap("YlOrRd")     # Sequential: Yellow-Orange-Red
cmap = plt.get_cmap("Paired")     # Qualitative: 12 paired colors

Key ColorBrewer palettes organized by type:

  • Sequential: Blues, Greens, Oranges, Reds, Purples, Greys, YlOrRd, YlGnBu, BuGn, PuRd
  • Diverging: BrBG, PiYG, PRGn, PuOr, RdBu, RdGy, RdYlBu, RdYlGn, Spectral
  • Qualitative: Accent, Dark2, Paired, Pastel1, Pastel2, Set1, Set2, Set3

All ColorBrewer palettes include variants for different numbers of classes (3 through 12), accessible via seaborn:

palette = sns.color_palette("Set2", n_colors=5)