Plot guides › Chart types

Bland-Altman plot

A Bland-Altman plot compares two measurement methods by plotting the difference between them against their mean, with lines for the mean bias and the 95% limits of agreement (bias ± 1.96 SD).

Example bland-altman plot made with matplotlib
Rendered from the code below, with example data.

When to use it

Ask for it in pltchat

Upload your file and type something like:

"Bland-Altman plot of method A vs method B with bias and limits of agreement"

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(27)
truth = rng.uniform(60, 180, 70)
a = truth + rng.normal(0, 4, 70)
b = truth + 3 + rng.normal(0, 5, 70)

mean = (a + b) / 2
diff = a - b
bias, sd = diff.mean(), diff.std(ddof=1)

fig, ax = plt.subplots(figsize=(6.4, 4))
ax.scatter(mean, diff, s=16, alpha=0.7)
for y, label in [(bias, "bias"), (bias + 1.96 * sd, "+1.96 SD"),
                 (bias - 1.96 * sd, "−1.96 SD")]:
    ax.axhline(y, ls="--" if label != "bias" else "-", color="gray")
    ax.text(mean.max(), y, f" {label}: {y:.1f}", va="center", fontsize=8)
ax.set_xlabel("Mean of A and B (mg/dL)")
ax.set_ylabel("A − B (mg/dL)")
plt.tight_layout()
plt.show()

Make this with your data

Upload a CSV, Excel, JSON or Parquet file. Your first plot is always free.

Related plots