title: Add text to bar graph ggplot2 (asterisks for significance)
body: <p>I have a rather complex graph (at least for me) and I would like to add asterisks for the comparisons that are significant. I have coded the significant comparisons in a separate column of my data frame. Here is my data:</p>
  <pre><code>data = structure(list(mask = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 2L, 
  2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 
  4L), .Label = c(&quot;roi1&quot;, &quot;roi2&quot;, &quot;roi3&quot;, &quot;roi4&quot;), class = &quot;factor&quot;), 
      comp = structure(c(1L, 1L, 2L, 2L, 3L, 3L, 1L, 1L, 2L, 2L, 
      3L, 3L, 1L, 1L, 2L, 2L, 3L, 3L, 1L, 1L, 2L, 2L, 3L, 3L), .Label = c(&quot;comp1&quot;, 
      &quot;comp2&quot;, &quot;comp3&quot;), class = &quot;factor&quot;), type = structure(c(1L, 
      2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 
      1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L), .Label = c(&quot;rand&quot;, &quot;real&quot;
      ), class = &quot;factor&quot;), dv = c(0.5001, 0.5002, 0.5001, 0.5002, 
      0.5002, 0.7658, 0.5, 0.8692, 0.4998, 0.8568, 0.5001, 0.8814, 
      0.5001, 0.5002, 0.5003, 0.5001, 0.5, 0.6943, 0.5003, 0.669, 
      0.5, 0.6205, 0.5001, 0.686), std = c(0.0258, 0.0351, 0.0351, 
      0.0258, 0.0258, 0.0347, 0.0346, 0.0256, 0.0347, 0.0254, 0.0239, 
      0.0351, 0.0351, 0.0347, 0.0256, 0.0347, 0.0256, 0.0258, 0.0348, 
      0.0256, 0.0351, 0.0254, 0.0254, 0.0347), sig = c(0L, 0L, 
      0L, 0L, 0L, 1L, 0L, 1L, 0L, 1L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 
      1L, 0L, 1L, 0L, 1L, 0L, 1L)), class = &quot;data.frame&quot;, row.names = c(NA, 
  -24L))
  
  head(data)
    mask  comp type     dv    std sig
  1 roi1 comp1 rand 0.5001 0.0258   0
  2 roi1 comp1 real 0.5002 0.0351   0
  3 roi1 comp2 rand 0.5001 0.0351   0
  4 roi1 comp2 real 0.5002 0.0258   0
  5 roi1 comp3 rand 0.5002 0.0258   0
  6 roi1 comp3 real 0.7658 0.0347   1
  </code></pre>
  <p>This is the code for my graph:</p>
  <pre><code>ggplot(data=data, aes(x=comp, y=dv, fill=type)) +
    geom_bar(stat=&quot;identity&quot;, position=position_dodge()) +
    theme_bw() + facet_wrap(. ~ mask, ncol=2) + 
    scale_y_continuous(name = &quot;accuracy&quot;, limits = c(0, 1)) +
    geom_errorbar(aes(ymin=dv-std, ymax=dv+std), width=.2,
                  position=position_dodge(.9))
  </code></pre>
  <p><a href="https://i.stack.imgur.com/RCsLE.png" rel="nofollow noreferrer">Current graph</a></p>
  <p>However, I would like to add an asterisk between the bars where the corresponding real row has a 1 in the sig column e.g. between roi1 comp3 rand and real. The finished graph should look like this:</p>
  <p><a href="https://i.stack.imgur.com/gLwRE.png" rel="nofollow noreferrer">Desired graph</a></p>
  <p>Does anyone have an idea how to do this?</p>
  <p>Cheers,
  Max</p>