ggplot2 icon indicating copy to clipboard operation
ggplot2 copied to clipboard

docs: Improve extending ggplot2 vignette?

Open olivroy opened this issue 6 months ago • 0 comments

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.

https://github.com/business-science/tidyquant/pull/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

olivroy avatar Dec 15 '23 19:12 olivroy