svgpcurve
p-curve
Do the significant results look like they come from real effects (right-skewed) or from selective reporting of null effects (flat or left-skewed)?
How to read it
- Read only the significant results: each point is the share of their p-values in one .01-wide bin.
- A curve that falls from left to right (many very small p-values) is right-skewed, as real effects produce.
- A flat curve near 20% looks like no effect; a curve rising towards .05 suggests p-hacking.
- Callout 1: Many p-values below .01: right skew.
- Callout 2: The flat 20% line: no true effect.
- Callout 3: The 33%-power curve: weak evidence.
Watch out
- p-curve says whether the significant results carry evidential value, not how large the effect is.
- With only a handful of significant results the bins are coarse; trust the Stouffer tests over the picture.
Defaults
- Significant results
- 0
- Number of significant results behind the curve, shown in the legend (0 hides it).
- Range 0 to 100,000, step 1
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.
- Bins are (0, .01], (.01, .02], … (.04, .05] of two-sided p-values from results significant in the favoured direction.
- With no true effect p-values are uniform below .05, so every bin holds 20%. The 33%-power curve is what studies with power 1/3 would give (z tests, as χ²(1)).
# p-curve — Codesplash Chart Lab (recipe "pcurve")
# controls: k=0
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("pcurve-demo.csv", keep_default_na=False, na_values=[""]) # demo data (only empty cells are missing): Chart Lab → Code → Download demo CSV
BIN = "p-value"
OBS = "observed %"
NULL = "no effect %"
P33 = "33% power %"
K = 0 # significant results behind the curve (0 = not shown)
d = df.dropna(subset=[BIN, OBS]).sort_values(BIN)
ticks = [f"{b:.2f}".lstrip("0") for b in d[BIN]]
x = np.arange(len(d))
fig, ax = plt.subplots(figsize=(6.5, 4.5))
if NULL:
ax.plot(x, d[NULL], color=PALETTE[3], linestyle=":", linewidth=1.4, label="no effect")
if P33:
ax.plot(x, d[P33], color=PALETTE[2], linestyle="--", linewidth=1.4, label="33% power")
ax.plot(x, d[OBS], color=PALETTE[0], linewidth=2.2, marker="o", label=f"observed ({K:g} significant)" if K else "observed")
for xi, v in zip(x, d[OBS]):
ax.annotate(f"{v:.0f}%", (xi, v), textcoords="offset points", xytext=(0, 7), ha="center", fontsize=8)
ax.set_xticks(x, ticks)
ax.set_ylim(0, 100)
ax.set_xlabel(f"p-value (bin upper edge; {BIN})")
ax.set_ylabel(f"share of significant results (%; {OBS})")
ax.legend(frameon=False)
plt.show()Needs pandas, numpy, matplotlib · reads pcurve-demo.csv · app theme from the optional codesplash helper
# p-curve — Codesplash Chart Lab (recipe "pcurve")
# controls: k=0
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("pcurve-demo.csv", keep_default_na=False, na_values=[""]) # demo data (only empty cells are missing): Chart Lab → Code → Download demo CSV
BIN = "p-value"
OBS = "observed %"
NULL = "no effect %"
P33 = "33% power %"
K = 0 # significant results behind the curve (0 = not shown)
d = df.dropna(subset=[BIN, OBS]).sort_values(BIN)
ticks = [f"{b:.2f}".lstrip("0") for b in d[BIN]]
fig = go.Figure()
if NULL:
fig.add_scatter(x=ticks, y=d[NULL], mode="lines", line=dict(color=PALETTE[3], dash="dot"), name="no effect")
if P33:
fig.add_scatter(x=ticks, y=d[P33], mode="lines", line=dict(color=PALETTE[2], dash="dash"), name="33% power")
fig.add_scatter(x=ticks, y=d[OBS], mode="lines+markers+text", text=[f"{v:.0f}%" for v in d[OBS]], textposition="top center",
line=dict(color=PALETTE[0], width=3), name=f"observed ({K:g} significant)" if K else "observed")
fig.update_layout(xaxis_title=f"p-value ({BIN})", yaxis_title=f"share of significant results (%; {OBS})", yaxis_range=[0, 100])
fig.show()Needs pandas, numpy, plotly · reads pcurve-demo.csv · app theme from the optional codesplash helper
# p-curve — Codesplash Chart Lab (recipe "pcurve")
# controls: k=0
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("pcurve-demo.csv", check.names = FALSE, stringsAsFactors = FALSE, na.strings = "") # empty cells are missing; Chart Lab → Code → Download demo CSV
bin_col <- "p-value"
obs_col <- "observed %"
null_col <- "no effect %"
p33_col <- "33% power %"
k_sig <- 0 # significant results behind the curve (0 = not shown)
d <- df[!is.na(df[[bin_col]]) & !is.na(df[[obs_col]]), ]
d <- d[order(d[[bin_col]]), ]
d$tick <- factor(sub("^0", "", sprintf("%.2f", d[[bin_col]])), levels = sub("^0", "", sprintf("%.2f", d[[bin_col]])))
long <- data.frame(tick = d$tick, share = d[[obs_col]], curve = if (k_sig > 0) sprintf("observed (%g significant)", k_sig) else "observed")
if (!is.null(null_col)) long <- rbind(long, data.frame(tick = d$tick, share = d[[null_col]], curve = "no effect"))
if (!is.null(p33_col)) long <- rbind(long, data.frame(tick = d$tick, share = d[[p33_col]], curve = "33% power"))
long$curve <- factor(long$curve, levels = unique(long$curve))
p <- ggplot(long, aes(tick, share, colour = curve, linetype = curve, group = curve)) +
geom_line(linewidth = 0.9) +
geom_point(data = long[long$curve == levels(long$curve)[1], ], size = 2) +
geom_text(data = long[long$curve == levels(long$curve)[1], ], aes(label = sprintf("%.0f%%", share)), vjust = -0.9, size = 3, show.legend = FALSE) +
scale_colour_manual(values = c(cs_cat[1], cs_cat[4], cs_cat[3])[seq_along(levels(long$curve))], name = NULL) +
scale_linetype_manual(values = c("solid", "dotted", "dashed")[seq_along(levels(long$curve))], name = NULL) +
coord_cartesian(ylim = c(0, 100)) +
labs(x = paste0("p-value (", bin_col, ")"), y = paste0("share of significant results (%; ", obs_col, ")")) + theme_cs
print(p)Needs ggplot2 · reads pcurve-demo.csv · app theme from the optional codesplashr helper