title: How To Avoid Density Curve Getting Cut Off In Plot
body: <p>I am working on an assignment using R and the fitted density curve that is overlaid on the histogram is cut off at it's peak.</p>
  
  <p>Example:</p>
  
  <pre><code>x &lt;- rexp(1000, 0.2)
  hist(x, prob = TRUE)
  lines(density(x), col = "blue", lty = 3, lwd = 2)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/mLH0y.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mLH0y.png" alt="enter image description here"></a></p>
  
  <p>I have done a search on the internet for this but didn't find anything addressing this problem.  I have tried playing with the margins, but that doesn't work.  Am I missing something in my code?</p>
  
  <p>Thank you for your help!</p>