Skip to content
svgdrapery

Drapery plot (p-value functions)

At every confidence level at once, which effects are compatible with each study and with the pooled result?

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

How to read it

  1. Read each curve as a p-value function: it peaks at p = 1 at the estimate and falls away on both sides.
  2. Where a curve crosses a horizontal level α, the two crossings are its (1 − α) confidence interval.
  3. Compare the bold pooled curve with the shaded prediction curve: the second shows where a new study's true effect may land.
  1. Callout 1: The pooled estimate: p = 1.
  2. Callout 2: The p = .05 line: crossings give the 95% CI.
  3. Callout 3: One study's p-value function.

Watch out

  • A narrow pooled curve doesn't mean the studies agree; check the prediction curve and the spread of the study curves.
  • The p at the null line is not the probability that there is no effect.

Defaults

Log scale (ratios)
Off
Ratios on a log axis so equal ratios look equally far from 1.
Null value
0
Where 'no effect' sits: 0 for differences, 1 for ratios (dashed).
Range -1,000,000 to 1,000,000, step 0.1
Level line (α)
0.05
Draws p = α; where the pooled curve crosses it is the (1 − α) confidence interval.
Range 0.001 to 0.5, step 0.005

Pinned in the code

  • Draws the meta-analysis engine's numbers as given (codesplash.stats.meta_lab in Python ≡ codesplashr in R); the chart computes nothing statistical.
  • Each curve is p(θ) = P(|T| ≥ |estimate − θ| / SE): 1 at the estimate, falling on both sides. Studies use the normal distribution; the pooled curve uses z or Knapp–Hartung t; the prediction curve uses SE² + τ² with t on k − 2 df.
  • The horizontal dashed line is p = α; the bold segment on it is the pooled (1 − α) interval read off the curve.
# Drapery plot (p-value functions) — Codesplash Chart Lab (recipe "drapery")
# controls: log=false, reference=0, alpha=0.05
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"]
# non-colour encodings per series (same table as the app: series are never told apart by colour alone)
SERIES_DASHES = ["-", (0, (6, 3)), (0, (1.5, 2.5)), (0, (8, 3, 2, 3)), (0, (12, 4)), (0, (3, 3)), (0, (8, 2, 2, 2, 2, 2)), (0, (1.5, 5))]

df = pd.read_csv("drapery-demo.csv", keep_default_na=False, na_values=[""])  # demo data (only empty cells are missing): Chart Lab → Code → Download demo CSV
df["kind"] = pd.Categorical(df["kind"].astype("string"), categories=["study", "pooled", "prediction"])

_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 = "risk ratio"
P = "p-value"
CURVE = "curve"
KIND = "kind"
LOG, REFERENCE, ALPHA = False, 0, 0.05
d = df.dropna(subset=[X, P])
kind_of = (lambda s: s[KIND].astype(str)) if KIND else (lambda s: pd.Series("study", index=s.index))
fig, ax = plt.subplots(figsize=(7.5, 5))
for name, s in d.groupby(d[CURVE].astype(str), sort=False):
    s = s.sort_values(X)
    k = kind_of(s).iloc[0]
    if k == "prediction":
        ax.fill_between(s[X], 0, s[P], color=PALETTE[2], alpha=0.18, lw=0, label="prediction")
        ax.plot(s[X], s[P], color=PALETTE[2], alpha=0.6, linewidth=1, linestyle=SERIES_DASHES[2])  # dotted outline, as in the app
    elif k == "pooled":
        ax.plot(s[X], s[P], color="black", linewidth=2.2, label="pooled", zorder=4)
    else:
        ax.plot(s[X], s[P], color=PALETTE[0], alpha=0.55, linewidth=1)
ax.axhline(ALPHA, color=REF, linestyle="--", linewidth=1)
ax.text(1.01, ALPHA, f"{100 * (1 - ALPHA):g}% CI", transform=ax.get_yaxis_transform(), va="center", fontsize=8)
ax.axvline(REFERENCE, color=REF, linestyle=":", linewidth=1)
if LOG:
    ax.set_xscale("log")
ax.set_ylim(0, 1)
ax.set_xlabel(X)
ax.set_ylabel("p-value")
ax.legend(frameon=False)
plt.show()

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