Choosing the Right Chart
A chart is only useful if it answers a question quickly and honestly. Choosing the right chart type, and avoiding a few classic tricks that mislead readers, matters as much as the analysis behind it.
Start with the question
Before you draw anything, say in one sentence what the chart should show. Most questions fall into a few families, and each family has a natural chart.
| Your question is about… | Example | Best chart | Code |
|---|---|---|---|
| Comparing categories | Revenue by county | Bar chart (sorted) | ax.bar(), ax.barh(), sns.barplot() |
| Change over time | Monthly sales | Line chart | ax.plot(), sns.lineplot() |
| Distribution of one variable | Sizes of customer orders | Histogram or box plot | ax.hist(), sns.histplot(), sns.boxplot() |
| Relationship between two numbers | Temperature vs. soda sales | Scatter plot | ax.scatter(), sns.scatterplot() |
| Parts of a whole | Share of sales by payment method | Stacked bar, or a pie with 2–4 slices | ax.bar(..., bottom=...), ax.pie() |
| Many pairs of variables | Correlations between 6 columns | Heatmap | sns.heatmap() |
Why these choices work
Bar charts for comparisons
People judge lengths from a common baseline very accurately, so bars are the clearest way to compare amounts. Sort the bars (largest first, or largest at the top for horizontal bars) unless the categories have a natural order, such as days of the week.
Line charts for time
A line connects points in order and makes rises, falls and seasonal patterns easy to see. Use lines only when the x-axis is ordered (dates, months, years); connecting unrelated categories such as counties with a line suggests a trend that doesn't exist.
Histograms and box plots for distributions
An average hides the shape of the data. A histogram shows whether values cluster, spread out or have a long tail; a box plot compares the median and spread of several groups side by side.
Scatter plots for relationships
Each dot is one observation. An upward drift suggests a positive relationship, a downward drift a negative one, and a shapeless cloud suggests little relationship. Look out for curved patterns and outliers that a single number would hide.
A good chart, step by step
import pandas as pd
import matplotlib.pyplot as plt
revenue = pd.Series({"Kisumu": 7420, "Nairobi": 11400, "Nakuru": 3300}).sort_values()
fig, ax = plt.subplots(figsize=(6, 3))
bars = ax.barh(revenue.index, revenue.values, color="tab:blue")
ax.bar_label(bars, padding=3) # exact values at the end of each bar
ax.set_xlabel("Revenue (KES)")
ax.set_title("Nairobi brings in the most revenue")
ax.spines[["top", "right"]].set_visible(False) # remove clutter
plt.show()
What the chart shows: three horizontal bars with Nairobi (11400) at the top, Kisumu (7420) in the middle and Nakuru (3300) at the bottom, each labelled with its value. Because barh() draws the first item at the bottom, sorting from smallest to largest puts the biggest bar on top. The title states the finding rather than just naming the data, so a busy reader gets the message without studying the chart.
How charts mislead (and how to avoid it)
| Problem | Why it misleads | Better |
|---|---|---|
| Bar chart y-axis starting above zero | A 5% difference can look like 300% | Start bar axes at zero (ax.set_ylim(bottom=0)) |
| Pie chart with many slices | People can't compare similar angles | A sorted bar chart |
| 3-D effects | Perspective distorts sizes | Flat 2-D charts |
| Two y-axes on one chart | The scales can be chosen to suggest any relationship | Two charts side by side |
| Too many colours | The reader doesn't know what matters | Grey for context, one strong colour to highlight |
| Missing labels or units | "Sales" in KES? Units? Thousands? | Label axes with units: "Revenue (KES)" |
Truncated axes are the classic trick. If two branches earned KES 98,000 and KES 102,000 and the y-axis starts at 96,000, one bar looks three times taller than the other. Line charts may zoom in on a range, because they show change rather than size, but bars must start at zero.
Design checklist
- Title that states the main message.
- Axis labels with units (KES, °C, number of orders).
- Sorted categories unless there is a natural order.
- Direct labels on bars or lines where possible, instead of making readers match colours to a legend.
- Colour with purpose, and colour-blind-friendly palettes (avoid relying on red versus green alone).
- Source and date of the data in a caption when sharing outside your team.
Test your chart on a friend: show it for five seconds, then ask what it says. If they can't tell you, simplify it. The code for each chart type is on Matplotlib Basics and Seaborn.
Key points
- Match the chart to the question: bars compare, lines show time, histograms and box plots show distributions, scatter plots show relationships.
- Sort bars, start bar axes at zero and label everything with units.
- Avoid 3-D, crowded pies and dual axes.
- A title that states the finding makes a chart far more useful.
Tip: use the ← and → keys to move between pages.
