Skip to main content
Albero Academy

Chart Recipes

Ready-made patterns for the charts you make most often.

Applied Matplotlib9 min

A few complete, reusable recipes for common needs — copy, adapt, done. Each combines the pieces from earlier modules into a finished chart.

A clean ranked bar chart

horizontal, sorted, minimal
s = df.groupby("programme")["package"].mean().sort_values()
fig, ax = plt.subplots(figsize=(8, 5))
ax.barh(s.index, s.values, color="steelblue")
ax.set_title("Average package by programme")
ax.spines[["top", "right"]].set_visible(False)
for i, v in enumerate(s.values):
ax.text(v, i, f" {v:.1f}", va="center") # value labels
fig.tight_layout()

Time series with a moving average

raw + trend
fig, ax = plt.subplots(figsize=(12, 4))
ax.plot(ts.index, ts["sales"], alpha=0.3, label="daily")
ax.plot(ts.index, ts["sales"].rolling(7).mean(), color="crimson", label="7-day avg")
ax.legend(); fig.autofmt_xdate()

Key takeaways

  1. 01A sorted barh with value labels and hidden spines is a clean ranking chart.
  2. 02Plot faint raw data plus a bold moving average to show a trend clearly.
  3. 03Add value labels with a loop of ax.text for at-a-glance reading.
  4. 04Keep a snippets file of recipes you reuse.

Finished this chapter?

Mark it complete to track your progress through Matplotlib.