svglabbe
L'Abbé plot
Does the treatment's benefit depend on the baseline risk?
How to read it
- Read x as the control arm's risk, y as the treatment arm's.
- On the diagonal: no effect.
- Below the diagonal: treatment has fewer events; bubble size is the study's size.
- Callout 1: Larger study, near the diagonal.
- Callout 2: Below the diagonal: favours treatment.
- Callout 3: The no-difference line.
Watch out
- A trend here doesn't prove baseline risk changes the effect: arm risks share measurement error.
Defaults
No settings: the chart draws one way.
Pinned in the code
- Draws the meta-analysis engine's numbers as given (codesplash.stats.meta in Python ≡ codesplashr in R); the chart computes nothing statistical.
- x = control (group 2) risk, y = treatment (group 1) risk, equal axes; marker area ∝ participants.
- The diagonal is no difference; a constant risk ratio is a line through the origin.
# L'Abbé plot — Codesplash Chart Lab (recipe "labbe")
# controls: defaults
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
try:
import codesplash as cs # optional: the app's chart theme
except ImportError:
cs = None
if cs:
cs.use_codesplash(dark=False)
PALETTE = cs.palette(dark=False)["categorical"] if cs else plt.rcParams["axes.prop_cycle"].by_key()["color"]
df = pd.read_csv("labbe-demo.csv", keep_default_na=False, na_values=[""]) # demo data (only empty cells are missing): Chart Lab → Code → Download demo CSV
_tokens = cs.palette(dark=False) if cs else {}
SEQ = _tokens.get("sequential", ["#eff6fd", "#1a469d"]) # sequential ramp (low → high)
DIV = _tokens.get("diverging", ["#c13e2e", "#f3f5f8", "#0859ac"]) # negative, midpoint, positive
REF = _tokens.get("reference", "#4e5661")
GREY = _tokens.get("dim", "#ced1d6")
R1 = "risk, treatment"
R2 = "risk, control"
WEIGHT = "participants"
LABEL = "study"
d = df.dropna(subset=[R1, R2])
hi = min(1.0, max(0.05, d[[R1, R2]].to_numpy().max()) * 1.1)
w = d[WEIGHT] if WEIGHT else pd.Series(1.0, index=d.index)
fig, ax = plt.subplots(figsize=(6, 6))
ax.plot([0, hi], [0, hi], color=REF, linestyle="--", linewidth=1) # equal risk in both arms
ax.scatter(d[R2], d[R1], s=20 + 280 * w / w.max(), color=PALETTE[0], alpha=0.65, edgecolors=PALETTE[0])
if LABEL:
for _, r in d.iterrows():
ax.annotate(str(r[LABEL]), (r[R2], r[R1]), fontsize=7, xytext=(4, 3), textcoords="offset points")
ax.set_xlim(0, hi)
ax.set_ylim(0, hi)
ax.set_aspect("equal")
ax.set_xlabel(R2)
ax.set_ylabel(R1)
plt.show()Needs pandas, numpy, matplotlib · reads labbe-demo.csv · app theme from the optional codesplash helper
# L'Abbé plot — Codesplash Chart Lab (recipe "labbe")
# controls: defaults
import numpy as np
import pandas as pd
import plotly.express as px
import plotly.graph_objects as go
try:
import codesplash as cs # optional: the app's chart theme
except ImportError:
cs = None
if cs:
cs.use_codesplash(dark=False)
PALETTE = cs.palette(dark=False)["categorical"] if cs else px.colors.qualitative.Plotly
df = pd.read_csv("labbe-demo.csv", keep_default_na=False, na_values=[""]) # demo data (only empty cells are missing): Chart Lab → Code → Download demo CSV
_tokens = cs.palette(dark=False) if cs else {}
SEQ = _tokens.get("sequential", ["#eff6fd", "#1a469d"]) # sequential ramp (low → high)
DIV = _tokens.get("diverging", ["#c13e2e", "#f3f5f8", "#0859ac"]) # negative, midpoint, positive
REF = _tokens.get("reference", "#4e5661")
GREY = _tokens.get("dim", "#ced1d6")
R1 = "risk, treatment"
R2 = "risk, control"
WEIGHT = "participants"
LABEL = "study"
d = df.dropna(subset=[R1, R2])
hi = min(1.0, max(0.05, d[[R1, R2]].to_numpy().max()) * 1.1)
w = d[WEIGHT] if WEIGHT else pd.Series(1.0, index=d.index)
fig = go.Figure()
fig.add_scatter(x=[0, hi], y=[0, hi], mode="lines", line=dict(color=REF, dash="dash", width=1), name="equal risk")
fig.add_scatter(x=d[R2], y=d[R1], mode="markers", marker=dict(size=6 + 24 * np.sqrt(w / w.max()), color=PALETTE[0], opacity=0.65), name="study", text=d[LABEL].astype(str) if LABEL else None)
fig.update_xaxes(range=[0, hi], title=R2)
fig.update_yaxes(range=[0, hi], title=R1, scaleanchor="x")
fig.show()Needs pandas, numpy, plotly · reads labbe-demo.csv · app theme from the optional codesplash helper
# L'Abbé plot — Codesplash Chart Lab (recipe "labbe")
# controls: defaults
library(ggplot2)
has_cs <- isTRUE(requireNamespace("codesplashr", quietly = TRUE)) # optional: the app's chart theme
theme_cs <- if (has_cs) codesplashr::theme_codesplash(dark = FALSE) else theme_minimal()
cs_cat <- if (has_cs) codesplashr::cs_palette(dark = FALSE)$categorical else grDevices::palette.colors(8, "Okabe-Ito")
if (has_cs) update_geom_defaults("text", list(colour = codesplashr::cs_palette(dark = FALSE)$foreground))
df <- read.csv("labbe-demo.csv", check.names = FALSE, stringsAsFactors = FALSE, na.strings = "") # empty cells are missing; Chart Lab → Code → Download demo CSV
df[["study"]] <- factor(df[["study"]])
tok <- if (has_cs) codesplashr::cs_palette(dark = FALSE) else list()
seq_ramp <- if (is.null(tok$sequential)) c("#eff6fd", "#1a469d") else tok$sequential # low → high
div_ramp <- if (is.null(tok$diverging)) c("#c13e2e", "#f3f5f8", "#0859ac") else tok$diverging # −, 0, +
ref_col <- if (is.null(tok$reference)) "#4e5661" else tok$reference
grey_col <- if (is.null(tok$dim)) "#ced1d6" else tok$dim
r1_col <- "risk, treatment"
r2_col <- "risk, control"
weight_col <- "participants"
label_col <- "study"
d <- df[!is.na(df[[r1_col]]) & !is.na(df[[r2_col]]), ]
d$r1 <- d[[r1_col]]; d$r2 <- d[[r2_col]]
d$w <- if (is.null(weight_col)) rep(1, nrow(d)) else d[[weight_col]]
hi <- min(1, max(0.05, d$r1, d$r2) * 1.1)
p <- ggplot(d, aes(r2, r1, size = w)) +
geom_abline(slope = 1, intercept = 0, colour = ref_col, linetype = "dashed") + # equal risk in both arms
geom_point(colour = cs_cat[1], alpha = 0.65) +
scale_size_area(max_size = 9, guide = "none") +
coord_fixed(xlim = c(0, hi), ylim = c(0, hi)) +
labs(x = r2_col, y = r1_col) + theme_cs
if (!is.null(label_col)) p <- p + geom_text(aes(label = .data[[label_col]]), size = 2.2, nudge_y = hi * 0.02, show.legend = FALSE)
print(p)Needs ggplot2 · reads labbe-demo.csv · app theme from the optional codesplashr helper