Hi my density plot shows fringes/dips between points when there are only several points, see this picture:
http://www.imagesup.net/?di=3141413124212
# show fringes
test = as.data.frame( sample(0:5,1000,replace=T) )
colnames(test) = c('mon')
ggplot(test, aes(x=mon)) + geom_density(binwidth=1, size=1)
# normal
test = as.data.frame( sample(0:20,1000,replace=T) )
colnames(test) = c('mon')
ggplot(test, aes(x=mon)) + geom_density(binwidth=1, size=1)
Anybody know how to fix it?
Try changing the adjust=
parameter to change the bandwidth used to estimate the density: ggplot(test, aes(x=mon)) + geom_density(binwidth=1, size=1, adjust=2)
. As the ?stat_density
help page suggets, check out the parameters to density
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.