Skip to content

Day 05 Part 1 — Data Visualization Basics: Agenda

A chart that is wrong is worse than no chart. A chart that is right but unreadable is nearly as bad. Data visualization is the skill that turns analysis into understanding — it is the bridge between your findings and your audience's decisions. Every chart you make is an argument. Make it clearly and honestly.

Session Overview

Duration: 3 hours Prerequisite: EDA — you need data to visualize Tools: matplotlib, seaborn in Jupyter Lab


Learning Objectives

By the end of this session you will be able to:

  • Understand matplotlib's Figure/Axes architecture and use it to build any chart type
  • Use seaborn for statistical visualizations with less code
  • Apply the chart selection framework: match the chart to the question and data type
  • Apply design principles: data-ink ratio, color as signal, annotation, and honest axes
  • Build a multi-panel analytics figure that tells a complete story
  • Recognize and avoid the most common chart mistakes and misleading constructions

The Chart Selection Mental Model

Before writing a single line of code, ask two questions:

1. What relationship am I showing? 2. What type of data am I working with?

If you want to show... Use this chart
How a value changes over time Line chart
Comparison between a few categories Vertical bar chart
Comparison with many categories or long names Horizontal bar chart
Distribution of one numeric variable Histogram or box plot
Distribution compared across groups Box plot or violin plot per group
Relationship between two numeric variables Scatter plot (+ trend line)
Relationship among many variables Correlation heatmap or pair plot
Part-to-whole (2–5 segments) Stacked bar; pie chart only when the "more than half" story is the point
Part-to-whole over time Stacked bar chart or 100% area chart
Geographic distribution Choropleth map
Flow between states Sankey or funnel chart

The pie chart default

Most analysts reach for a pie chart to show category breakdowns. For more than 4–5 slices, angles are impossible to compare accurately. A horizontal bar chart shows the same information and lets readers compare values precisely. Reserve pie charts for the "X is more than half" story with 2–4 segments.

Decision rule

When unsure, default to a bar chart for comparisons and a line chart for time series. These two chart types communicate the vast majority of business questions accurately and without cognitive overhead.


Session Flow

Time Topic File
0:00 – 0:45 Matplotlib basics — anatomy and chart types 01-matplotlib-basics
0:45 – 1:15 Seaborn — statistical charts with clean defaults 02-seaborn-basics
1:15 – 1:45 Chart selection guide 03-chart-selection
1:45 – 2:15 Dashboard design basics 04-dashboard-design-basics
2:15 – 2:40 Visualization best practices 05-visualization-best-practices
2:40 – 3:00 Mini project 06-mini-project

Matplotlib vs Seaborn — When to Use Which

Both libraries produce publication-quality charts. Seaborn is built on top of matplotlib, so you can always mix them.

Task Matplotlib Seaborn
Full control over every pixel Best Harder
Statistical charts (KDE, violin, pair plot) Verbose Best
Correlation heatmaps Possible Best
Regression plots Verbose Best
Custom multi-panel figures (gridspec) Best Both
Quick exploratory charts in a notebook Verbose Best
Programmatic chart generation (50+ charts) Best Both

For mid-level analysts

Learn both APIs fluently. In practice, you will use seaborn for exploratory work and matplotlib for production charts where every element needs precise control — axis tick formatting, custom annotations, exact layout for a specific slide size.

For senior analysts

Build a standard chart template function that wraps your company style guide: font, colors, spine removal, footer. Apply it to every figure. When stakeholders see consistent charts across all your decks, it builds credibility before anyone reads a single number.

Tools Setup

import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
import numpy as np

# Apply a clean base style
plt.style.use("seaborn-v0_8-whitegrid")

# Set seaborn theme
sns.set_theme(style="whitegrid", palette="muted")
sns.set_context("notebook")  # options: paper, notebook, talk, poster

# Common rcParams for consistent styling
plt.rcParams.update({
    "font.family":        "sans-serif",
    "axes.spines.top":    False,
    "axes.spines.right":  False,
    "axes.grid":          True,
    "grid.alpha":         0.3,
    "grid.linestyle":     "--",
    "figure.dpi":         100,
})

# Load sample data
df = pd.read_csv("orders_clean.csv", parse_dates=["order_date"])
df["total"] = df["quantity"] * df["unit_price"]
completed = df[df["status"] == "completed"].copy()

Previous: EDA Interview Questions | Next: Matplotlib Basics