Small multiples (facet grid)
Small multiples repeat the same chart once per group in a grid with shared axes. Each panel stays uncluttered, and readers can still compare across panels.
When to use it
- Too many groups for one chart (more than five lines).
- Each group's pattern matters, not only the overlap.
Ask for it in pltchat
Upload your file and type something like:
"one small panel per country, shared y axis, 3 columns"
pltchat writes the loader and the plot for your columns, runs it in your browser and shows you the code.
The matplotlib code
Self-contained with example data; swap in pd.read_csv(...) or
pd.read_excel(...) for your own file.
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
rng = np.random.default_rng(24)
countries = ["Austria", "Belgium", "Chile", "Denmark", "Estonia", "France"]
years = np.arange(2000, 2025)
slopes = dict(zip(countries, rng.normal(0.8, 0.5, len(countries))))
df = pd.DataFrame([{"country": c, "year": y,
"value": 50 + slopes[c] * (y - 2000) + rng.normal(0, 1.5)}
for c in countries for y in years])
fig, axes = plt.subplots(2, 3, figsize=(7.5, 4.5), sharex=True, sharey=True)
for ax, (country, g) in zip(axes.flat, df.groupby("country")):
ax.plot(df["year"], df["value"], ".", color="lightgray", ms=2)
ax.plot(g["year"], g["value"], color="C0")
ax.set_title(country, fontsize=10)
fig.supxlabel("Year")
fig.supylabel("Index")
plt.tight_layout()
plt.show()
Upload a CSV, Excel, JSON or Parquet file. Your first plot is always free.