Visualization Cookbook

Pick your question, choose a dataset, get production-ready Python code. Every recipe is designed around what story your data tells — not just which chart looks nice.

Message First

Start with the question you're answering, not the chart type. The visualization follows the insight.

Data-to-Ink

Every pixel should earn its place. Remove gridlines, borders, and colours that don't carry meaning.

Anchor in Context

Numbers without context are noise. Show benchmarks, thresholds, or comparisons that make the data meaningful.

Sometimes a Table

If your audience needs exact values or your data has <5 items, a clean table often beats any chart.

Chart Type Guide

When to use each chart — and when not to. Inspired by the Chartosaur principles.

▪ Bar Chart

Compare values across categories. The workhorse of data viz.

Use when: Comparing ≤15 categories on one measure. Horizontal bars for long labels.
Avoid: 3D bars, excessive categories, missing zero baseline.

▮ Histogram

Show the shape of a single continuous variable's distribution.

Use when: You want to see skewness, outliers, or modality. Choose bin widths carefully.
Avoid: Too few bins (hides shape) or too many (noise). Don't use for categories.

☐ Box Plot

Compare distributions across groups — shows median, IQR, and outliers.

Use when: Comparing spread and central tendency across 3–12 groups.
Avoid: When your audience doesn't know how to read box plots. Consider violin or jitter instead.

● Scatter Plot

Reveal relationships between two continuous variables.

Use when: Exploring correlation, clusters, or outliers. Add trend line for emphasis.
Avoid: Overplotting (>5k points without transparency). Consider hex bins or density instead.

⎯ Line Chart

Show trends over a continuous, ordered dimension (usually time).

Use when: Data has a natural order. Limit to 4–5 lines max.
Avoid: Connecting categorical data or unordered groups. Don't truncate y-axis for trend charts.

■ Heatmap

Show patterns in matrices — correlation tables, cross-tabs, or time grids.

Use when: You have two categorical/ordinal axes and a continuous fill value.
Avoid: More than ~20 items per axis. Use diverging colour scales for correlation.

▤ Stacked Bar

Show composition — how parts sum to a whole.

Use when: Showing shares across ≤5 categories. Use 100% stacking for share comparison.
Avoid: Too many segments (>5). Hard to compare middle segments — put the key one at the base.

♣ Violin Plot

Like box plots but show the full distribution shape via kernel density.

Use when: Distributions are bimodal or otherwise non-normal. Half-violins + jitter is powerful.
Avoid: When groups are small (n < 30). KDE can be misleading with small samples.

⋯ Lollipop / Dot Plot

Like bar charts but with less ink. Great for rankings.

Use when: Ranking items, showing gaps to a target, or before/after comparisons.
Avoid: When your audience expects bars. Lollipops work best for data-savvy viewers.

☷ Table

Sometimes the most honest, readable format. Don't force a chart.

Use when: ≤5 rows, exact values matter, or your data tells multiple stories at once.
Avoid: Large tables (>20 rows) without highlighting. Use conditional formatting or sparklines.