Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Improve extending ggplot2 vignette? #5590

Closed
olivroy opened this issue Dec 15, 2023 · 2 comments · Fixed by #5721
Closed

docs: Improve extending ggplot2 vignette? #5590

olivroy opened this issue Dec 15, 2023 · 2 comments · Fixed by #5721

Comments

@olivroy
Copy link
Contributor

olivroy commented Dec 15, 2023

https://ggplot2.tidyverse.org/dev/articles/extending-ggplot2.html

Maybe it could have a little section about the new guides improvements?

I think it should mention dropped_aes ? I am not sure I did this correctly, but in tidyquant, I made these edits to silence those warnings.

business-science/tidyquant#242

Also, the current example in the vignette seems to involve a deprecated function.

StatDensityCommon <- ggproto("StatDensity2", Stat, 
                             required_aes = "x",
                             default_aes = aes(y = stat(density)),
                             
                             compute_group = function(data, scales, bandwidth = 1) {
                                 d <- density(data$x, bw = bandwidth)
                                 data.frame(x = d$x, density = d$y)
                             }  
)

ggplot(mpg, aes(displ, drv, colour = stat(density))) + 
    stat_density_common(bandwidth = 1, geom = "point")
#> Warning: `stat(density)` was deprecated in ggplot2 3.4.0.
#> ℹ Please use `after_stat(density)` instead.
#> This warning is displayed once every 8 hours.
#> Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
#> generated.

ggproto docs

Also, maybe the ggproto ... could be improved a little? Currently, it only says "list of members", maybe it could be a little more precise and point to the correct place.

https://ggplot2.tidyverse.org/dev/reference/ggproto.html?q=ggproto#arguments

Thanks

@teunbrand
Copy link
Collaborator

teunbrand commented Feb 28, 2024

Guide extensions are covered in #5693

@olivroy
Copy link
Contributor Author

olivroy commented Feb 28, 2024

Looking good! thanks for taking good care of noobs :)

@teunbrand teunbrand added this to the ggplot2 3.5.1 milestone Mar 5, 2024
teunbrand added a commit that referenced this issue Mar 18, 2024
* document `Stat$dropped_aes`

* replace `stat()` with `after_stat()`

* tweak ggproto docs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants