title: How to overlay density histogram with gamma distribution fit in R?
body: <p>I am new to R and would like to add a fit to a gamma distribution to my histogram. I would like the gamma distribution fit to overlay my histogram.</p>
  
  <p>I am able to calculate the gamma distribution with the <code>dgamma</code> function and also with the <code>fitdist</code> function. However, I am not able to overlay this gamma distribution as a fit onto my histogram.</p>
  
  <p>This is the code I tried:</p>
  
  <pre><code>hist(mydata, breaks = 30, freq = FALSE, col = "grey")
  
  lines(dgamma(mydata, shape = 1))
  </code></pre>
  
  <p>The code I tried does not overlay the gamma distribution fit onto my histogram. I only get the histogram without the fit.</p>