This is Module 3 of the Data Analyst to Data Scientist path. You already know how to make charts. This module is about making charts that answer a question at a glance, for a reader who will spend five seconds on them. It uses the same shop data as Module 1 and Module 2, so you can check every number.
You’ll build: a one-page brief with charts whose titles state their findings.
You need: the CSV files from Module 2, plus pip install matplotlib.
1. Start from the question
Before opening any tool, write the question the chart answers, in one sentence. “Show revenue” is not a question. “Is revenue growing?” is, and so is “Which country brings in the most?”. The question decides the chart:
| Question | Chart | Why |
|---|---|---|
| How did it change over time? | Line | The slope shows direction and speed |
| Which is biggest? | Sorted horizontal bars | Lengths are easy to compare, labels stay readable |
| How do two measures relate? | Scatter plot | Each point is one item, and patterns show up as shapes |
| What share does each part have? | Bars, or a single stacked bar | Lengths compare more accurately than pie slices |
2. Change over time: a line
Question: is revenue growing? Save as chart_line.py:
import matplotlib
matplotlib.use("svg")
import matplotlib.pyplot as plt
import pandas as pd
orders = pd.read_csv("orders.csv", parse_dates=["order_date"])
monthly = orders.groupby(orders["order_date"].dt.to_period("M"))["amount"].sum()
fig, ax = plt.subplots(figsize=(6.4, 3.4))
ax.plot(monthly.index.strftime("%b %Y"), monthly.values, marker="o", linewidth=2.5, color="#4f7cff")
ax.set_title("Revenue grew every month, from 125 to 220", loc="left", fontsize=13, fontweight="bold")
ax.set_ylabel("Revenue")
ax.set_ylim(0, 250) # start at zero: the growth is real, not an axis effect
for x, y in zip(monthly.index.strftime("%b %Y"), monthly.values):
ax.annotate(f"{y:.0f}", (x, y), textcoords="offset points", xytext=(0, 8), ha="center")
ax.spines[["top", "right"]].set_visible(False)
fig.tight_layout()
fig.savefig("revenue_by_month.svg", facecolor="white")
print("saved revenue_by_month.svg")
Three choices make it readable:
- The title states the finding. A reader who only reads the title still gets the answer.
- The axis starts at zero. With three points, a cropped axis would make a modest rise look dramatic.
- Values are labelled on the points, so nobody has to read them off the axis.
3. Comparing categories: sorted bars
Question: which country brought in the most revenue? Save as chart_bar.py:
import matplotlib
matplotlib.use("svg")
import matplotlib.pyplot as plt
import pandas as pd
orders = pd.read_csv("orders.csv")
customers = pd.read_csv("customers.csv")
df = orders.merge(customers, on="customer_id", how="left", validate="many_to_one")
by_country = df.groupby("country")["amount"].sum().sort_values()
fig, ax = plt.subplots(figsize=(6.4, 2.8))
colors = ["#9aa4b2"] * (len(by_country) - 1) + ["#4f7cff"] # highlight only the answer
ax.barh(by_country.index, by_country.values, color=colors)
ax.set_title("Mexico brought in the most revenue in Q1", loc="left", fontsize=13, fontweight="bold")
ax.set_xlabel("Revenue, January to March")
for y, v in enumerate(by_country.values):
ax.text(v + 3, y, f"{v:.0f}", va="center")
ax.spines[["top", "right"]].set_visible(False)
fig.tight_layout()
fig.savefig("revenue_by_country.svg", facecolor="white")
print(by_country.to_string())
print("saved revenue_by_country.svg")
country
CO 105
AR 160
MX 260
saved revenue_by_country.svg
The bars are sorted so the order is the answer, the winning bar is the only coloured one, and values sit at the end of each bar. Horizontal bars also leave room for long category names, which vertical bars squeeze.
4. A checklist before you share a chart
- Does the title state the finding, not just the measure?
- Is the chart type the simplest one that answers the question?
- Do bar charts start at zero?
- Is colour used only to highlight what matters?
- Are values labelled where the reader needs them, and is the unit clear?
- Would it still make sense printed in black and white?
Claus Wilke’s free book Fundamentals of Data Visualization is the best next read for the reasoning behind these choices.
Project: a one-page brief
Pick a question from your own work and write a one-page brief with three charts, each with a title that states its finding, and a two-sentence summary at the top. Then show it to a colleague for ten seconds and ask what they took away. If their answer isn’t your summary, change the charts, not the summary.
Next: Module 4, probability and statistical inference: reporting estimates with their uncertainty.
Prepared with AI assistance and reviewed by an editor before publication. Editorial & AI policy.