-2

I have no idea why this simple command does not work?

    set.seed(12345)
    x<-rnorm(1000,0,10)
    hist(x)
    curve(dnorm(x,0, 10), add=TRUE, yaxt="n", col="red", log=FALSE)
Héctor Garrido
  • 185
  • 1
  • 14

1 Answers1

2

You are overlaying density over a frequency graph. You need to convert your histogram to a density plot.

hist(x, freq = FALSE)
curve(dnorm(x,0, 10), add=TRUE, col="red", log=FALSE)

enter image description here

Gregor Thomas
  • 136,190
  • 20
  • 167
  • 294
Divi
  • 1,614
  • 13
  • 23