0

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

Cettt
  • 10,939
  • 7
  • 31
  • 53
user3149762
  • 15
  • 1
  • 2
  • 6

1 Answers1

2

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)

enter image description here

Sven Hohenstein
  • 78,180
  • 16
  • 134
  • 160