A chart has one job: make a point obvious faster than a table would. Picking the library is the easy part. Picking the chart is where most beginners go wrong.
Start from the question, not the chart
| Question | Chart |
|---|---|
| How does a number change over time? | Line chart |
| How do categories compare? | Bar chart (horizontal if labels are long) |
| How is one number spread out? | Histogram or box plot |
| Are two numbers related? | Scatter plot |
| How does a number vary across two categories? | Heatmap |
| What share does each part make up? | Stacked bar, or a pie only if there are two or three parts |
If you cannot say the question in one sentence, you are not ready to draw the chart.
Matplotlib: full control
Matplotlib is the foundation; most Python plotting libraries, Seaborn included, are built on it. It gives you control over every element, which is exactly what you need for report-ready charts.
import matplotlib.pyplot as plt
fig, ax = plt.subplots(figsize=(8, 4))
ax.plot(monthly["month"], monthly["revenue"], marker="o")
ax.set_title("Monthly revenue, fictional store chain")
ax.set_xlabel("Month")
ax.set_ylabel("Revenue (₹ lakh)")
ax.axhline(target, linestyle="--", color="grey", label="Target")
ax.legend()
fig.tight_layout()Use the fig, ax = plt.subplots() style rather than calling plt.plot repeatedly. It scales to multiple charts in one figure and makes your code clearer.
Seaborn: statistics in one line
Seaborn works directly with pandas DataFrames and does grouping and statistics for you. Charts that take ten lines in Matplotlib take one in Seaborn.
import seaborn as sns
sns.boxplot(data=orders, x="city", y="delivery_mins")
sns.histplot(data=orders, x="amount", hue="city", element="step")
sns.heatmap(pivot, annot=True, fmt=".0f", cmap="Blues")
sns.scatterplot(data=orders, x="distance_km", y="delivery_mins", hue="city")The hue argument splits by a category with automatic colours and legend, which is the main reason analysts love Seaborn for exploration.
Use both together
Because Seaborn draws on Matplotlib axes, the common workflow is: draw with Seaborn, polish with Matplotlib.
fig, ax = plt.subplots(figsize=(8, 4))
sns.barplot(data=city_summary, x="late_rate", y="city", ax=ax, color="steelblue")
ax.set_title("Share of late deliveries by city")
ax.set_xlabel("Late deliveries (share of orders)")
ax.set_ylabel("")Five habits of readable charts
- A title that states the point, for example "Late deliveries are highest in the evening", not just "Late deliveries by hour".
- Label axes with units.
- Sort bars by value unless the categories have a natural order (like months).
- Start bar charts at zero. Cutting the axis exaggerates differences.
- Use colour to highlight, not to decorate. One highlighted bar in a grey chart is more powerful than ten colours.
Avoid these
- Pie charts with many slices. People cannot compare angles well.
- 3D charts. They distort values.
- Dual y-axes unless you really need them, and if you do, label both clearly.
Practise
Our Matplotlib track goes from line charts and labels to report-ready charts, and the Seaborn track covers categories, heatmaps and more, all checked in your browser.
Practise what you just read
Reading helps; writing the code yourself is what sticks. Start here: