Look for a relationship.
Compare paired measurements without pretending correlation is causation.
01 The idea
A scatter plot shows observations as pairs of measurements. It helps reveal trends, clusters, and unusual points without connecting observations into an invented sequence. Marker transparency can help with overlap, but it does not solve every density problem. Treat an apparent relationship as a prompt for investigation, not automatic proof that one variable causes the other.
02 The experiment
Read it once. Predict what will happen. Then copy it into a .py file and run it in your local Python setup.
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
minutes = [10, 15, 22, 30, 38, 45]
issues = [1, 0, 2, 2, 4, 3]
fig, ax = plt.subplots(figsize=(6, 3.5), layout="constrained")
ax.scatter(minutes, issues, s=65, alpha=0.7, color="#ed5027", edgecolors="#71331e")
ax.set(xlabel="Review time (minutes)", ylabel="Issues found", title="A relationship worth investigating")
ax.grid(alpha=0.15)
fig.savefig("matplotlib-scatter.png", dpi=140, bbox_inches="tight")
plt.close(fig)
print("Saved matplotlib-scatter.png")Saved matplotlib-scatter.png

03 Under the hood
- 1
Each x value is paired with the y value at the same position. The sample is deliberately small and illustrative.
- 2
s controls marker area, not diameter. If you encode another variable through size, explain its units and scale.
- 3
A trend might reflect task complexity rather than a causal effect of review time. Investigate confounding variables and collect appropriate evidence before drawing conclusions.
04 Your turn, builder
Plot project effort against reported defects and annotate the point with the most defects.
Reveal one possible solution +
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
x, y = [12, 20, 35], [1, 4, 2]
fig, ax = plt.subplots(figsize=(6, 3.5), layout="constrained")
ax.scatter(x, y, color="#ed5027", s=70)
ax.annotate("Inspect this task", xy=(20, 4), xytext=(13, 4.5), arrowprops={"arrowstyle": "->"})
ax.set(xlabel="Effort (hours)", ylabel="Defects", ylim=(0, 5.5))
fig.savefig("challenge.png", dpi=140, bbox_inches="tight")
plt.close(fig)
print("Saved challenge.png")05 Check your signal
Does a visible scatter trend establish causation?
Experiment. Logged.
When you can explain the idea and make the example your own, mark it complete. Your log stays in this browser.
Keep exploring
Go deeper with the official Python guide ↗.