Plot bacterial growth curves (OD600)
Growth curves track optical density (OD600) over time. Averaging the replicate wells per strain and plotting on a log y-axis makes the exponential phase a straight line, so growth rates are easy to compare.
When to use it
- Plate reader or spectrophotometer exports with time and OD per well.
- Comparing strains, media or treatments.
Ask for it in pltchat
Upload your file and type something like:
"mean OD600 per strain over time with a shaded SD band, log y axis"
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(31)
hours = np.arange(0, 24.5, 0.5)
def logistic(t, k, r, lag):
return 0.02 + k / (1 + np.exp(-r * (t - lag)))
fig, ax = plt.subplots(figsize=(6.4, 4))
for strain, (k, r, lag) in {"WT": (1.2, 0.8, 7), "ΔgeneX": (0.9, 0.55, 9),
"ΔgeneX + pX": (1.15, 0.75, 7.5)}.items():
reps = logistic(hours, k, r, lag) * rng.normal(1, 0.05, (3, 1)) \
+ rng.normal(0, 0.005, (3, hours.size))
mean, sd = reps.mean(0), reps.std(0)
ax.plot(hours, mean, label=strain)
ax.fill_between(hours, np.clip(mean - sd, 1e-3, None), mean + sd, alpha=0.25)
ax.set_yscale("log")
ax.set_xlabel("Time (h)")
ax.set_ylabel("OD600")
ax.legend()
plt.tight_layout()
plt.show()
Upload a CSV, Excel, JSON or Parquet file. Your first plot is always free.