Axis Labels and Titles
Always label your charts
Section titled “Always label your charts”Without labels, your chart is incomplete. McKinney’s rule of thumb: set_xlabel names
the x-axis, set_title names the whole subplot, and both can be set together with one
call to ax.set(title=..., xlabel=..., ylabel=...) — handy once you’re labelling many
subplots at once.
flowchart LR
A["Raw plot"] --> B["ax.set_xlabel('Day')"]
B --> C["ax.set_ylabel('Orders')"]
C --> D["ax.set_title('what changed, not just the chart type')"]
D --> E["Reader understands the chart without extra context"]
import matplotlib.pyplot as plt
x = [1, 2, 3, 4]
y = [100, 120, 90, 150]
plt.figure(figsize=(7, 4))
plt.plot(x, y, marker="o")
plt.title("Daily orders")
plt.xlabel("Day")
plt.ylabel("Orders")
plt.tight_layout()
plt.show()Include units
Section titled “Include units”Examples:
- Revenue (₹)
- Duration (seconds)
- Conversion rate (%)
A good title explains the question, not just the chart type.
Bad: “Line chart”
Better: “Daily orders increased after campaign launch”
Continue to Legends and Colors to distinguish multiple series clearly.
🧪 Try It Yourself
Section titled “🧪 Try It Yourself”Exercise 1 – Title and axis labels together
Section titled “Exercise 1 – Title and axis labels together”Exercise 2 – Custom tick labels
Section titled “Exercise 2 – Custom tick labels”Exercise 3 – Rotate long labels
Section titled “Exercise 3 – Rotate long labels”pch.coffeeTagline
pch.coffeeCtapch.feedbackHeading
pch.feedbackSubheading