title: Overlay normal curve to histogram in R
body: <p>I have managed to find online how to overlay a normal curve to a histogram in R, but I would like to retain the normal "frequency" y-axis of a histogram. See two code segments below, and notice how in the second, the y-axis is replaced with "density". How can I keep that y-axis as "frequency", as it is in the first plot.</p>
  
  <p><strong>AS A BONUS:</strong> I'd like to mark the SD regions (up to 3 SD) on the density curve as well. How can I do this? I tried <code>abline</code>, but the line extends to the top of the graph and looks ugly.</p>
  
  <pre><code>g = d$mydata
  hist(g)
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/7bl5b.png" alt="enter image description here"></p>
  
  <pre><code>g = d$mydata
  m&lt;-mean(g)
  std&lt;-sqrt(var(g))
  hist(g, density=20, breaks=20, prob=TRUE, 
       xlab="x-variable", ylim=c(0, 2), 
       main="normal curve over histogram")
  curve(dnorm(x, mean=m, sd=std), 
        col="darkblue", lwd=2, add=TRUE, yaxt="n")
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/1dfiE.png" alt="enter image description here"></p>
  
  <p>See how in the image above, the y-axis is "density". I'd like to get that to be "frequency".</p>