Skip to content
svgmetareg-bubble

Meta-regression bubble plot

Does the study effect change with a study-level moderator?

Demo data · seed 20261101 · 13 rows · default settings · 640 × 360SVG, lightSVG, darkDemo CSV

How to read it

  1. Read x as the moderator, y as the effect.
  2. Bubble size shows weight.
  3. Read the line's slope and band for how the effect changes.
  1. Callout 1: A study at low latitude.
  2. Callout 2: Effects grow with latitude.
  3. Callout 3: Heavier studies count more.

Watch out

  • It's ecological: a study-level trend need not hold for individuals inside studies.

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 is b₀ + b₁·x from the engine (controls intercept, slope); the band is ± crit·√(v₀₀ + 2x·v₀₁ + x²·v₁₁) from the engine's coefficient covariance and critical value.
  • Weights are 1/(vᵢ + τ²) — larger bubbles pull the line harder.
# Meta-regression bubble plot — Codesplash Chart Lab (recipe "metareg-bubble")
# controls: defaults
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from scipy import stats

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("metareg-bubble-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")
X = "absolute latitude"
Y = "log risk ratio"
WEIGHT = "weight"
B0, B1 = None, None  # the fit the engine published
V00, V01, V11, CRIT = None, None, None, None
d = df.dropna(subset=[X, Y])
w = d[WEIGHT] if WEIGHT else pd.Series(1.0, index=d.index)
fig, ax = plt.subplots(figsize=(7.5, 5))
if B0 is not None and B1 is not None:
    pad = (d[X].max() - d[X].min()) * 0.05
    xs = np.linspace(d[X].min() - pad, d[X].max() + pad, 65)
    fit = B0 + B1 * xs
    if V00 is not None and V01 is not None and V11 is not None:
        se = np.sqrt(np.maximum(0, V00 + 2 * xs * V01 + xs ** 2 * V11))  # Var(b0 + b1·x) from the coefficient covariance
        crit = CRIT if CRIT is not None else stats.norm.ppf(0.975)
        ax.fill_between(xs, fit - crit * se, fit + crit * se, color=PALETTE[0], alpha=0.15, lw=0)
    ax.plot(xs, fit, color=PALETTE[0], linewidth=1.5)
ax.scatter(d[X], d[Y], s=20 + 300 * w / w.max(), facecolors="none", edgecolors=REF)
ax.set_xlabel(X)
ax.set_ylabel(Y)
plt.show()

Needs pandas, numpy, matplotlib, scipy · reads metareg-bubble-demo.csv · app theme from the optional codesplash helper