title: How to remove curves after last datapoint in ggplot2
body: <p>I want to erase a part of a density curve in ggplot for places where there are no data points.
  If you add a density curve, the program automatically adds density estimation curve.
  I have to erase the part after the last data point. There are multiple curves, so setting a range to x-axis was not an option.
  For example, in the sample iris data, I want to remove the parts marked in orange.</p>
  <p><a href="https://i.stack.imgur.com/I3kEP.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/I3kEP.jpg" alt="enter image description here" /></a></p>
  <pre><code>library(ggplot2)
  library(dplyr)
  data(iris)
  summary(iris)
  
  setosa &lt;- iris %&gt;%filter(Species== 'setosa')
  versicolor &lt;- iris %&gt;%filter(Species== 'versicolor')
  virginica &lt;- iris %&gt;%filter(Species== 'virginica')
  
  summary(setosa)
  summary(versicolor)
  summary(virginica)
  
  p &lt;- ggplot(setosa, aes(x = Sepal.Length, colour = Species)) + 
    geom_density()
  p
  </code></pre>