title: R: by group mirrored histogram using ggplot2
body: <p>I would like to get a mirrored histogram <strong>by group</strong> using ggplot as illustrated in the picture at the bottom.</p>
  <pre><code>library(ggplot2)
  data2 &lt;- data.frame(
    type = c( rep(&quot;Top 1&quot;, n_segment),
              rep(&quot;Top 2&quot;, n_segment),
              rep(&quot;Bottom 1&quot;, n_segment),
              rep(&quot;Bottom 2&quot;, n_segment)),
    value = c( rnorm(n_segment, mean=5),
               rnorm(n_segment, mean=12),
               rnorm(n_segment, mean=-5),
               rnorm(n_segment, mean=-12))
  )
  
  # Represent it
  data2 %&gt;%
    ggplot( aes(x=value, fill=type)) +
    geom_density( color=&quot;#e9ecef&quot;, alpha=0.6) 
  
  </code></pre>
  <p>For now I am getting this:</p>
  <p><a href="https://i.stack.imgur.com/GNHM2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GNHM2.png" alt="enter image description here" /></a></p>
  <p>But I would like to mirror them as follows:
  <a href="https://i.stack.imgur.com/BXRSM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BXRSM.png" alt="enter image description here" /></a></p>