4. Data Visualization & Storytelling
Choosing the Right Chart, Avoiding Misleading Axes & KPI Reports
Communicate insights clearly and honestly: match chart types to analytical questions, avoid truncated bar-chart axes and 3D pie clutter, and build executive KPI summaries.
- Select the clearest chart type based on whether you are showing comparison, trend, distribution, or relationship
- Spot and fix misleading visualizations (non-zero bar baselines, dual y-axes, over-crowded pie charts)
- Structure concise executive KPI reports with context (vs target / previous period)
Imagine walking into an executive review with a slide showing a bar chart where Product A (98% uptime) looks three times taller than Product B (96% uptime)—because the y-axis starts at 95% instead of 0%. Someone asks a tough question, trust in your numbers evaporates, and the meeting derails.
A script that builds a glossy chart telling the wrong visual story is worse than no chart at all. Great data storytelling combines sharp chart selection, visual honesty, and decision-ready KPI context.
1. Chart Selection Matrix
Bar Chart
Compare categories
Line Chart
Trends over time
Histogram
Distribution & skew
Scatter Plot
Two-var correlation
Bar charts compare categories (start Y at 0!), line charts track continuous time, histograms show spread, and scatter plots reveal relationships.
Start with the question you are answering, then pick the chart whose geometry matches how human eyes decode data:
| Analytical Question | Best Chart | Avoid | Why |
|---|---|---|---|
| Compare values across categories | Sorted Horizontal / Vertical Bar | 3D Pie / Donut | Eyes judge bar length accurately; angles & 3D depth distort area |
| Trend over continuous time | Line Chart | Unordered Bar / Pie | Slopes show acceleration, seasonality, and dips immediately |
| Distribution of one variable | Histogram or Boxplot | Single average bar | Averages hide bimodal peaks, skew, and extreme outliers |
| Relationship between 2 variables | Scatter Plot | Line chart on unsorted X | Reveals correlation, clusters, and anomalies |
| Part-to-whole (2–4 groups) | Stacked Bar (or sorted Bar) | 10+ slice Pie Chart | Too many slices create unreadable rainbow confetti |
For nominal categories like Hardware, Books, and Office, always sort bars from largest to smallest (not alphabetically!). Reserve left-to-right natural order only for sequential labels like Jan, Feb, Mar or Beginner, Intermediate, Advanced.
2. Visual Honesty Rules (Before vs After)
Rule 1: Bar Charts MUST Start at Zero (ax.set_ylim(bottom=0))
Because bar charts encode numbers by bar length, truncating the axis visually exaggerates tiny differences:
# MISLEADING: Makes 98% look 3x taller than 96%!
ax.bar(["Plan A", "Plan B"], [98.0, 96.0])
ax.set_ylim(95, 100) # BAD for bar charts!
# HONEST: Full zero baseline shows true 2-percentage-point difference
ax.bar(["Plan A", "Plan B"], [98.0, 96.0])
ax.set_ylim(0, 105) # GOOD: proportional visual length(Note: Line charts tracking small fluctuations like body temperature 98.2°F–99.1°F or stock ticks may zoom in on a non-zero axis, because line charts encode slope/trajectory rather than bar length—just label the y-axis prominently!)
Rule 2: Ditch Dual Y-Axes and Rainbow Palettes
- Dual Y-Axes (
twinx()): By stretching the left and right scales arbitrarily, you can force any two unrelated lines to cross dramatically. Prefer two stacked subplots (plt.subplots(2, 1, sharex=True)) sharing the same x-axis instead! - Color as a Spotlight, Not Decoration: Color every bar neutral slate (
#94a3b8) and highlight the single takeaway category or anomalous spike in indigo (#4f46e5) or coral (#e11d48).
Rule 3: Never Ship Naked Numbers in KPI Reports
A standalone metric tells a reader nothing about whether to celebrate or act:
- Weak (naked number):
Monthly Revenue: $42,000 - Actionable KPI:
Monthly Revenue: $42,000 (+14.1% MoM | 105% of $40k target) -> [ON TRACK]
Every executive KPI line should pair 4 elements:
- Current Value (formatted cleanly with unit and commas)
- Comparison Delta (
+14.1% MoMor vs prior week) - Target / Threshold (
105% of $40k target) - Action Status (
ON TRACK,WATCH, orACTION NEEDED)
For Revenue or Completion Rate, being above target is ON TRACK. For Bug Rate, Churn, or API P95 Latency, lower is better—never mark a 140% latency spike as ON TRACK just because it exceeded the threshold!
3. Putting Highlight Colors & Context Together in Matplotlib
Here is how a senior analyst translates those rules directly into Python—sorting bars descending, keeping a 0 baseline, muting background bars, and annotating exact values:
categories = ["Office", "Books", "Hardware"]
revenues = [14_200, 18_500, 42_000]
colors = ["#cbd5e1", "#cbd5e1", "#4f46e5"] # Spotlight top performer only!
fig, ax = plt.subplots(figsize=(7, 3.8))
bars = ax.barh(categories, revenues, color=colors)
ax.set_xlim(left=0, right=48_000)
ax.bar_label(bars, fmt="$%,.0f", padding=6)
ax.set_title("Hardware Drives 56% of Q4 Revenue", fontweight="bold")
ax.spines[["top", "right"]].set_visible(False)
fig.tight_layout()Notice the chart title itself states the takeaway ("Hardware Drives 56% of Q4 Revenue") rather than a generic label like "Chart 1: Revenue".
Try It Yourself in the Playground
Build a clean Markdown executive KPI summary generator in Python that handles both "higher is better" metrics (Revenue, Completion) and "lower is better" metrics (Refund Rate):
Click “Run Code” to execute this snippet right in your browser.
Mini-Challenge: You want to show the market share of 11 different programming languages. Why should you use a sorted horizontal bar chart instead of a pie chart?
Quick Checkpoints
Why should bar charts almost always start their value axis at 0?
Which chart type is best for inspecting the relationship between study_hours and exam_score across 200 students?
You need to plot Daily Active Users (range: 10,000–50,000) alongside Error Rate % (range: 0.2%–1.5%) over 90 days. What is the cleanest, most honest layout?