Fix override.aes size to linewidth for linetype legend (#449)#450
Conversation
- overlay_function() now wraps geom_function() instead of the older stat_function(), matching modern ggplot2 conventions - Use linewidth instead of size in override.aes for line-based legend keys in mcmc-traces.R and ppd-distributions.R - Update documentation and tests accordingly Closes stan-dev#449
|
Thanks. this seems like a change we should make but we have a failing test: https://github.com/stan-dev/bayesplot/actions/runs/22910316067/job/66500925400?pr=450#step:7:1175 |
The override.aes change from size to linewidth affects the legend key rendering, so these snapshots need to be regenerated.
|
@jgabry only ubuntu fails, we can merge now right? |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #450 +/- ##
=======================================
Coverage 98.55% 98.55%
=======================================
Files 35 35
Lines 5864 5864
=======================================
Hits 5779 5779
Misses 85 85 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Actually, I have a question about this. I just checked the doc for |
Hey @jgabry, to reframe the pr, instead of 'superseded' i should say 'recommended alternative' . you should find it here exactly : https://ggplot2.tidyverse.org/news/index.html#ggplot2-332 |
jgabry
left a comment
There was a problem hiding this comment.
the API is compatible since we just pass
...through
I don't think this is fully true. For example stat_function(..., geom = "point", inherit.aes = FALSE) produces a point layer whereas geom_function(..., geom = "point", inherit.aes = FALSE) warns that geom is unknown and keeps the default function geom. Since overlay_function() exposes ... this would technically be breaking backwards compatibility. I'm not sure if anyone is actually trying to specify geom, so maybe not a big deal, but I think since stat_function isn't actually deprecated we should avoid making this change.
We don't need to close this PR though, we can keep the size -> linewidth fix if you remove the stat_function change.
As requested: stat_function isn't deprecated, and switching to geom_function could break backwards compatibility for users passing geom via overlay_function(...). Only the size -> linewidth fix in override.aes remains.
Fixes the
override.aesin thelinetypelegend formcmc_trace()divergence plots — changessizetolinewidth, which is the correct aesthetic for line widths since ggplot2 3.4.0.The
stat_function->geom_functionchange has been reverted per review feedback.