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
  • 11,460
  • 7
  • 35
  • 58
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
  • 80,497
  • 17
  • 145
  • 168