JetBrains / JetBrains/lets-plot
stat summary: add combined functions: fn_data: mean_sdl / mean_se
- Dominant language
- Kotlin
- Stars
- 1.8k
- Forks
- 60
- PR merge metrics
- No merged PRs in 30d
Description
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*
```Python
# 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..'))
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start at the stat="summary" implementation and trace how fn, fn_min, and fn_max are handled, then inspect the existing summary tests if available. Define the combined fn_data and fn_args behavior for mean_sdl and mean_se, including default y, ymin, and ymax aesthetics; done means both proposed examples produce the expected center and bounds.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin, python
- Domain
- data-visualization
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100