0

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?

XYZ
  • 105
  • 2
  • 9

1 Answers1

0

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

MrFlick
  • 195,160
  • 17
  • 277
  • 295