Stat summary can't produce the very common mean ± SD / SE chart (error bar / pointrange / ribbon). Its fn / fn_min / fn_max parameters take only point aggregations — count, sum, mean, median, min, max, lq, mq, uq — none of which express a spread-based interval.
What's missing is any spread-based bound (SD, SE). It's structurally different: ymin = mean − k·SD is not a single-column aggregation — it's derived jointly from the center and the dispersion of the same column, so it can't be modeled as an independent fn_min / fn_max, and there's currently no slot for it.
Proposed
Add a combined summary function parameter — the analog of ggplot2's fun.data — that returns center and bounds together as the computed variables ..y.., ..ymin.., ..ymax..:
fn_data="mean_sdl" — mean ± k·SD (ggplot2 default k = 2)
fn_data="mean_se" — mean ± k·SE
with a multiplier parameter (ggplot2 passes fun.args=list(mult=…)), e.g. fn_args={'mult': 1}. This is a new mechanism alongside fn / fn_min / fn_max (use one or the other), mirroring ggplot2's fun vs fun.data. Ideally stat="summary" + fn_data sets the default ymin/ymax aesthetics so they needn't be re-mapped.
Desirable API
# cleanest — the stat provides default y/ymin/ymax
geom_pointrange(data=df, stat="summary", fn_data="mean_sdl") # mean ± 2·SD
geom_pointrange(data=df, stat="summary", fn_data="mean_se", fn_args={'mult': 1})
# explicit form (also valid, for control)
geom_pointrange(data=df, stat="summary", fn_data="mean_sdl",
mapping=aes(y='..y..', ymin='..ymin..', ymax='..ymax..'))
Stat summary can't produce the very common mean ± SD / SE chart (error bar / pointrange / ribbon). Its fn / fn_min / fn_max parameters take only point aggregations —
count, sum, mean, median, min, max, lq, mq, uq— none of which express a spread-based interval.What's missing is any spread-based bound (SD, SE). It's structurally different: ymin = mean − k·SD is not a single-column aggregation — it's derived jointly from the center and the dispersion of the same column, so it can't be modeled as an independent fn_min / fn_max, and there's currently no slot for it.
Proposed
Add a combined summary function parameter — the analog of ggplot2's fun.data — that returns center and bounds together as the computed variables ..y.., ..ymin.., ..ymax..:
fn_data="mean_sdl"— mean ± k·SD (ggplot2 default k = 2)fn_data="mean_se"— mean ± k·SEwith a multiplier parameter (ggplot2 passes fun.args=list(mult=…)), e.g.
fn_args={'mult': 1}. This is a new mechanism alongside fn / fn_min / fn_max (use one or the other), mirroring ggplot2's fun vs fun.data. Ideallystat="summary"+fn_datasets the default ymin/ymax aesthetics so they needn't be re-mapped.Desirable API