Module 3 · Statistical Visualization with Seaborn

Section 1: Introduction to Seaborn and Statistical Plots

Seaborn vs Matplotlib · Themes · Distribution Plots · Box Plots · Violin Plots

🌊 Seaborn vs Matplotlib
  • Built on Matplotlib — enhances, not replaces it
  • Automatic statistical summaries (CI, regression)
  • Native pandas DataFrame support: data=df, x="col"
  • Use Seaborn for stats; Matplotlib for fine control
🎨 Themes & Palettes
  • sns.set_theme(style="whitegrid") — apply globally
  • Styles: whitegrid, darkgrid, white, dark, ticks
  • Palettes: deep, muted, pastel, bright, colorblind
  • sns.set_palette("colorblind") for accessibility
📊 Distribution Plots
  • sns.histplot(data, x="col", kde=True)
  • KDE overlay shows shape without bin sensitivity
  • sns.kdeplot() for smooth density estimation
  • Compare groups using the hue parameter
📦 Box Plots
  • sns.boxplot(data=df, x="cat", y="val")
  • Shows median, IQR, whiskers, and outlier points
  • Ideal for comparing distributions across categories
  • Add hue for a second categorical dimension
🎻 Violin Plots
  • sns.violinplot() — KDE + boxplot combined
  • Reveals bimodal or skewed shapes boxplots miss
  • split=True for two-group side-by-side comparison
  • More informative than boxplots for presentations
🧪 Lab 1 — Seaborn Statistical Plots
  • Part A: Member age distribution histplot with KDE
  • Part B: Revenue distribution comparison across segments
  • Apply colorblind palette and whitegrid theme
  • Export publication-quality PNG at 300 DPI