title: ggridges : P(X<0) does not visually match true probability density
body: <blockquote>
  <p>I do not understand why ggridges does not visually match the true probability of making a loss P(x&lt;0) which is 0.0765 in my case (first dpf at bottom; see chart below). How can I fix that?</p>
  </blockquote>
  <pre><code>n &lt;- 80000
  simrandwalk &lt;- function() {
  x &lt;- rnorm(n,mu_per,std_per)
  }
  ratioDsurFP1=0
  ratioDsurFP4=80/20
  mu_per=10
  std_per=7
  
  #proba loss
  perte1&lt;-pnorm(0,mu_per,std_per)
  
  dataf&lt;- data.frame(&quot;Valx&quot; = 1:n, &quot;Wt&quot; = 1:n, &quot;Code_série&quot;= 1:n)
  r&lt;-simrandwalk()
  dataf&lt;-rbind(dataf,list(1:n,r,rep(round(ratioDsurFP1,2),n)))
  dataf&lt;-tail(dataf,-n)
  
  mu_per=30
  std_per=35
  #proba loss
  perte4&lt;-pnorm(0,mu_per,std_per)
  mu_per4&lt;-mu_per
  std_per4&lt;-std_per
  r&lt;-simrandwalk()
  dataf&lt;-rbind(dataf,list(1:n,r,rep(round(ratioDsurFP4,2),n)))
  
  par(las=1,bty=&quot;l&quot;)
  
  x1&lt;-min(c(mu_per1-3*std_per1,mu_per4-3*std_per4))
  x2&lt;-max(c(mu_per1+3*std_per1,mu_per4+3*std_per4))
  
  mongraph&lt;-ggplot(dataf,aes(x=Wt,y=as.factor(Code_série),fill = ifelse(..x..&lt;0, &quot;lower than 0&quot;, 
  &quot;higher than 0&quot;)))+xlim(x1,x2)+stat_density_ridges(quantiles=2,scale=0.9,bandwidth=16,geom=&quot;density_ridges_gradient&quot;,calc_ecdf=TRUE,alpha=0.7,linetype=&quot;solid&quot;, size=0.5)+
  theme_classic()+theme(legend.position=&quot;right&quot;)+ scale_fill_manual(values = c(&quot;gray70&quot;,&quot;red&quot;), name = &quot;Probability&quot;)
  </code></pre>
  <p><a href="https://i.stack.imgur.com/UevmQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UevmQ.png" alt="enter image description here" /></a></p>
  <blockquote>
  <p>And here is the ecdf which is correct:
  <a href="https://i.stack.imgur.com/XDLbZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XDLbZ.png" alt="enter image description here" /></a></p>
  </blockquote>