Hi Thomas,
Here's a simple example of adding a KDE line to a plotted histogram:
set.seed(222)
x <- rnorm(100)
hist(x, freq=FALSE)
lines(density(x), lty=2, col=2, lwd=2)
Note the need to set the freq to FALSE -- otherwise hist will
calculate counts within bins rather than probability densities.
Hi list,
After a lot of tweaking i have managed to create a histogram with an
overlaying density plot. The histogram shows a sample of birth weights
of babies and the density plot shows birth weights from a much larger
reference populaton. My data is divided in 0.1 Kg bins so in the code
below bin
2 matches
Mail list logo