Course contentsShow
← Data Science
Lesson 1295 of 2,14532. Visualization with Matplotlib and SeabornFree lesson

Color Palettes: Sequential, Diverging, and Qualitative

Choosing appropriate color palettes based on data type and applying them using Seaborn's palette functions.

Color Palettes: Sequential, Diverging, and Qualitative

You'll learn how to choose the right color palette for your data type and apply it using Seaborn.

Why Color Palettes Matter

Not all color schemes work equally well for all data. Choosing the wrong palette can mislead viewers or make patterns invisible. Seaborn provides three palette families that match different data characteristics.

The Three Palette Types

Sequential Palettes

Use these when data has ordered values from low to high (temperature, age, salary). Sequential palettes progress from light to dark (or vice versa) in a single hue, showing magnitude naturally.

Think of it like a thermometer: lighter blues for cooler temps, darker blues for hotter.

Diverging Palettes

Use these when data has a meaningful midpoint with extremes in both directions (correlation from -1 to +1, change from baseline, survey responses from "strongly disagree" to "strongly agree"). Diverging palettes use two contrasting hues that meet at a neutral middle.

Like a political map: blue and red diverging from purple in the center.

Qualitative Palettes

Use these for categorical data with no inherent order (countries, product types, demographic groups). Qualitative palettes use distinct, unrelated hues so each category stands out equally.

Think of it like assigning team jerseys—each team needs a visually distinct color.

Applying Palettes in Seaborn

import seaborn as sns
import matplotlib.pyplot as plt

# Sequential: for ordered data
sns.set_palette("Blues")

# Diverging: for data with meaningful center
sns.set_palette("RdBu_r")  # red-blue reversed

# Qualitative: for categories
sns.set_palette("Set2")

# Or specify directly in a plot
sns.barplot(data=df, x='category', y='value', palette='Set1')

Key Takeaway: Match your palette to your data type—sequential for ordered magnitudes, diverging for data with a meaningful center, and qualitative for unordered categories. Seaborn makes applying these palettes simple with built-in options.