Box plot with individual points
Overlaying each observation as a jittered dot on top of a box plot shows the summary, the sample size and any clustering at once. It's a common request from reviewers.
When to use it
- Groups have fewer than about 100 points each.
- You want readers to see n and the raw distribution.
Ask for it in pltchat
Upload your file and type something like:
"box plot per genotype with the individual points jittered on top"
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 matplotlib.pyplot as plt
rng = np.random.default_rng(10)
data = {"WT": rng.normal(10, 2, 15), "KO": rng.normal(14, 3, 15),
"KO + rescue": rng.normal(11, 2.5, 15)}
fig, ax = plt.subplots(figsize=(4.8, 4))
ax.boxplot(list(data.values()), tick_labels=list(data.keys()), widths=0.5,
showfliers=False, medianprops={"color": "k"})
for i, vals in enumerate(data.values(), start=1):
ax.scatter(i + rng.uniform(-0.12, 0.12, vals.size), vals,
s=16, alpha=0.7, zorder=3)
ax.set_ylabel("Expression (a.u.)")
ax.spines[["top", "right"]].set_visible(False)
plt.tight_layout()
plt.show()
Upload a CSV, Excel, JSON or Parquet file. Your first plot is always free.