title: r ggplot plotly - fill area under the CDF curve
body: <p>Using ggplot2's <em>stat_ecdf( )</em> function, I have made a Cumulative Density Function plot. I am required to shade area under the CDF curve between two x-axis values and convert it to plotly output. Using the IRIS dataset, I have replicated the scenario with the following code:</p>
  
  <pre><code>library(ggplot2)
  
  iris &lt;- datasets::iris
  
  iris &lt;- iris[order(iris$Sepal.Length),]
  
  (plot_1 &lt;- ggplot(iris, aes(Sepal.Length)) + 
      stat_ecdf() +
      scale_x_reverse())
  
  plot_1_plotly &lt;- ggplotly(plot_1)
  plot_1_plotly
  
  (plot_2 &lt;- ggplot(iris, aes(Sepal.Length)) + 
      stat_ecdf(aes(ymin = 0, ymax = ..y..), geom = "ribbon", alpha = 0.2, 
      fill = "blue") +
      stat_ecdf(geom="step") +
      scale_x_reverse())
  
  plot_2_ggplotly &lt;- ggplotly(plot_2)
  plot_2_ggplotly
  </code></pre>
  
  <ul>
  <li><strong>plot_1</strong> produces <a href="https://i.stack.imgur.com/xdW8e.png" rel="nofollow noreferrer">this output</a>, which is a normal CDF curve (not shaded)</li>
  <li><strong>plot_1_plotly</strong> produces <a href="https://i.stack.imgur.com/dhyst.png" rel="nofollow noreferrer">this output</a>, which is the plotly version (not shaded)</li>
  <li><strong>plot_2</strong> produces <a href="https://i.stack.imgur.com/YUNnl.png" rel="nofollow noreferrer">this output</a>, which is my attempt at getting the area under the curve shaded (with help from the answer to <a href="https://stackoverflow.com/questions/26643799/how-to-get-ggplot-ecdf-to-plot-with-filled-background">this question</a>)</li>
  <li><strong>plot_2_plotly</strong> produces <a href="https://i.stack.imgur.com/AzNoi.png" rel="nofollow noreferrer">this output</a>, which is the plotly version of plot_2 </li>
  </ul>
  
  <p><strong>Question 1:</strong> In plot_2 output, how do I restrict the shaded area between two x-axis values (say x = 6 and x = 7)?</p>
  
  <p><strong>Question 2:</strong> When I convert plot_2 to plotly output i.e plot_2_plotly, why does the shaded area get messed up as shown in the output? How to get back to original form?</p>