svggalbraith
Galbraith (radial) plot
Which studies fall outside what one common effect would predict?
How to read it
- Read x as precision and y as the standardized estimate.
- Under a common effect, points fall within ±2 of the line.
- Points outside the band are the studies driving heterogeneity.
- Callout 1: The pooled slope.
- Callout 2: A study outside the band.
- Callout 3: The ±2 band.
Watch out
- With few studies the band says little about what's typical.
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.
- The line's slope is the common-effect estimate (engine control `slope`); the dashed lines are ±2 standard units, where ~95% of studies fall without heterogeneity.
- Studies outside the band are coloured and labelled.
# Galbraith (radial) plot — Codesplash Chart Lab (recipe "galbraith")
# 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("galbraith-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")
Z = "standardized estimate"
PREC = "precision (1/SE)"
LABEL = "study"
SLOPE = 0 # the common-effect estimate
d = df.dropna(subset=[Z, PREC])
x_max = d[PREC].max() * 1.08
outside = (d[Z] - SLOPE * d[PREC]).abs() > 2
fig, ax = plt.subplots(figsize=(7, 5.5))
ax.fill_between([0, x_max], [2, SLOPE * x_max + 2], [-2, SLOPE * x_max - 2], color=GREY, alpha=0.35, lw=0)
ax.plot([0, x_max], [0, SLOPE * x_max], color=REF, linewidth=1)
ax.scatter(d[PREC], d[Z], s=28, c=[PALETTE[1] if o else PALETTE[0] for o in outside], zorder=3)
if LABEL:
for _, r in d[outside].iterrows():
ax.annotate(str(r[LABEL]), (r[PREC], r[Z]), fontsize=8, xytext=(4, 4), textcoords="offset points")
ax.set_xlabel(PREC)
ax.set_ylabel(Z)
plt.show()Needs pandas, numpy, matplotlib · reads galbraith-demo.csv · app theme from the optional codesplash helper
# Galbraith (radial) plot — Codesplash Chart Lab (recipe "galbraith")
# 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("galbraith-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")
Z = "standardized estimate"
PREC = "precision (1/SE)"
LABEL = "study"
SLOPE = 0 # the common-effect estimate
d = df.dropna(subset=[Z, PREC])
x_max = d[PREC].max() * 1.08
outside = (d[Z] - SLOPE * d[PREC]).abs() > 2
fig = go.Figure()
fig.add_scatter(x=[0, x_max, x_max, 0, 0], y=[2, SLOPE * x_max + 2, SLOPE * x_max - 2, -2, 2], fill="toself", mode="lines", line=dict(color=GREY, width=0), name="± 2")
fig.add_scatter(x=[0, x_max], y=[0, SLOPE * x_max], mode="lines", line=dict(color=REF, width=1), name="common effect")
fig.add_scatter(x=d[PREC], y=d[Z], mode="markers", marker=dict(size=8, color=[PALETTE[1] if o else PALETTE[0] for o in outside]), name="study", text=d[LABEL].astype(str) if LABEL else None)
fig.update_layout(xaxis_title=PREC, yaxis_title=Z)
fig.show()Needs pandas, numpy, plotly · reads galbraith-demo.csv · app theme from the optional codesplash helper
# Galbraith (radial) plot — Codesplash Chart Lab (recipe "galbraith")
# 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("galbraith-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
z_col <- "standardized estimate"
prec_col <- "precision (1/SE)"
label_col <- "study"
slope <- 0 # the common-effect estimate
d <- df[!is.na(df[[z_col]]) & !is.na(df[[prec_col]]), ]
d$z <- d[[z_col]]; d$prec <- d[[prec_col]]
d$outside <- abs(d$z - slope * d$prec) > 2
x_max <- max(d$prec) * 1.08
band <- data.frame(x = c(0, x_max, x_max, 0), y = c(2, slope * x_max + 2, slope * x_max - 2, -2))
p <- ggplot() +
geom_polygon(data = band, aes(x, y), fill = grey_col, alpha = 0.35) +
annotate("segment", x = 0, xend = x_max, y = 0, yend = slope * x_max, colour = ref_col) +
geom_point(data = d, aes(prec, z, colour = outside), size = 2.2) +
scale_colour_manual(values = c("FALSE" = cs_cat[1], "TRUE" = cs_cat[2]), guide = "none") +
labs(x = prec_col, y = z_col) + theme_cs
if (!is.null(label_col) && any(d$outside)) p <- p + geom_text(data = d[d$outside, ], aes(prec, z, label = .data[[label_col]]), size = 2.8, nudge_y = 0.25)
print(p)Needs ggplot2 · reads galbraith-demo.csv · app theme from the optional codesplashr helper