I just plotted a histogram on R for some data, following:
hist(Y1, breaks=30)
I don't know how to draw a Kernel density estimate plot smoothly over the histogram plot.
All suggestion appreciated
I just plotted a histogram on R for some data, following:
hist(Y1, breaks=30)
I don't know how to draw a Kernel density estimate plot smoothly over the histogram plot.
All suggestion appreciated
You need freq = FALSE
in hist
.
set.seed(1)
Y1 <- rgamma(100, 10, 3)
hist(Y1, breaks = 30, freq = FALSE)
dens <- density(Y1)
lines(dens)