Dose-response curve (IC50 / EC50)
A dose-response curve plots response against log concentration and fits a sigmoidal four-parameter logistic (4PL) model. The midpoint of the curve is the IC50 or EC50.
When to use it
- Drug, toxin or ligand concentration series.
- You need an IC50/EC50 and a figure showing the fit.
Watch out: Put concentration on a log axis; on a linear axis the sigmoid is squashed into one corner.
Ask for it in pltchat
Upload your file and type something like:
"dose-response curve with a 4PL fit, log x axis, mark the IC50"
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
def four_pl(x, bottom, top, ic50, hill):
return bottom + (top - bottom) / (1 + (x / ic50) ** hill)
rng = np.random.default_rng(19)
conc = np.repeat(np.logspace(-3, 2, 8), 3) # µM, triplicates
resp = four_pl(conc, 5, 100, 0.8, 1.2) + rng.normal(0, 4, conc.size)
# Simple grid search fit (use scipy.optimize.curve_fit if you have SciPy)
best = min(((b, t, c, h) for b in np.linspace(0, 15, 16)
for t in np.linspace(90, 110, 21)
for c in np.logspace(-2, 1, 61) for h in np.linspace(0.5, 2.5, 21)),
key=lambda p: ((four_pl(conc, *p) - resp) ** 2).sum())
fig, ax = plt.subplots(figsize=(6.4, 4))
ax.scatter(conc, resp, s=18, color="k")
xs = np.logspace(-3.3, 2.3, 200)
ax.plot(xs, four_pl(xs, *best), color="C0")
ax.axvline(best[2], ls="--", color="gray")
ax.text(best[2] * 1.2, 90, f"IC50 = {best[2]:.2f} µM", color="gray")
ax.set_xscale("log")
ax.set_xlabel("Concentration (µM)")
ax.set_ylabel("Viability (% of control)")
plt.tight_layout()
plt.show()
Upload a CSV, Excel, JSON or Parquet file. Your first plot is always free.