Id like to use the ggplot stat_summary function with something like geom = "histogram" or geom = "kde". This is avail in python with kind="kde", but I am unable to find a good workaround in r. Thank you.
library(ggplot2)
data("iris")
ggplot(iris, aes(iris$Species, iris$Sepal.Length))+
stat_summary(fun.y= " mean", geom = "bar")
Try ggalt
package
library(ggalt)
#> Loading required package: ggplot2
m <- ggplot(faithful, aes(x = eruptions, y = waiting)) +
geom_point() +
xlim(0.5, 6) +
ylim(40, 110)
m + geom_bkde2d(bandwidth=c(0.5, 4))
m + stat_bkde2d(bandwidth=c(0.5, 4), aes(fill = ..level..), geom = "polygon")
Or use the default from ggplot2
package
m + geom_density_2d()
m + stat_density_2d(aes(fill = calc(level)), geom = "polygon")
Created on 2018-05-10 by the reprex package (v0.2.0).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.