The mapping
| Question | Chart |
|---|---|
| How has this changed over time? | Line |
| How do these categories compare? | Bar |
| How is this value distributed? | Histogram |
| Are these two measures related? | Scatter |
| What share of the whole? | Stacked bar — rarely pie |
Line — trend over time
fig, ax = plt.subplots(figsize=(10, 4))
ax.plot(monthly['month'], monthly['revenue'], marker='o')
ax.set_title('Revenue by month')
Use a line only when the x-axis is genuinely continuous — time, or an ordered numeric scale. A line between unordered categories implies a progression that does not exist.
Bar — comparing categories
fig, ax = plt.subplots(figsize=(8, 5))
region_totals = df.groupby('region')['revenue'].sum().sort_values()
ax.barh(region_totals.index, region_totals.values)
Sort by value rather than alphabetically — the ranking is usually the point. And use horizontal bars when category names are long, so labels stay readable.
Bar length encodes value. Truncating the axis exaggerates small differences into large ones, which is misleading whether or not you meant it to be. Line charts may be truncated; bars may not.
Histogram — distribution
ax.hist(df['revenue'], bins=30, edgecolor='white')
Bin count matters more than people expect. Too few hides the shape, too many turns it into noise. Try several before settling — 20 to 50 is a reasonable starting range.
Scatter — relationship
ax.scatter(df['spend'], df['revenue'], alpha=0.5)
alpha matters on any real dataset — without transparency, overlapping points hide density and a thousand points look much like a hundred.
Pie charts
People compare angles poorly. Anything beyond two or three slices is read more accurately as a sorted bar chart. Use a pie only when there are very few categories and the shares are obviously different.