title: ggplot cumulative frequency with groups
body: <p>I would like to construct cumulative count for two groups and reweight it to level 1. </p>
  
  <p>I know how to plot density in this case:</p>
  
  <pre><code>my_df = data.frame(col_1 = sample(c(0,1), 1000, replace = TRUE),
                     col_2 = sample(seq(1,100,by=1), 1000, replace = TRUE))
  my_df$col_1 &lt;- as.factor(my_df$col_1)
  ggplot(data = my_df, aes(x = col_2, group = col_1, col = col_1))+
    geom_density(position = 'dodge', size = 2)
  </code></pre>
  
  <p>Here is the plot:
  <a href="https://i.stack.imgur.com/LLfDO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LLfDO.png" alt="pdf"></a></p>
  
  <p>However, if I try to plot <code>cumsum</code> I am getting the following picture:<a href="https://i.stack.imgur.com/sNGtM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sNGtM.png" alt="cdf"></a></p>
  
  <p>As you can see second line starts where first line ends level. </p>
  
  <p>Is there fix for it? I can always try to do computations manually and plot it, but I wonder if there is ggplot solution? There are some solutions that I found on SO, but they do not involve scaling data to level 1.</p>