title: How to add significance of Tukey's test to ggplot2 figure with multiple facet?
body: <p>I generated a plot using a long format table, ggplot() and facet_wrap() functions in Rstudio. I want to add values of Tukey's tests applied to different levels of data and annotated with a system of stars (or letters) for significance.</p>
  <p>Here is the example code :</p>
  <pre><code># create a df for example
  a &lt;- paste0(&quot;Sample_&quot;, rep(1:100, 1))
  b &lt;- c(rep(&quot;Dubai&quot;, 30), rep(&quot;London&quot;, 35), rep(&quot;Bucarest&quot;, 35))
  c &lt;- c(rep(&quot;Sun&quot;, 16), rep(&quot;Rain&quot;, 16), rep(&quot;Cloud&quot;, 17), rep(&quot;Thunder&quot;, 16), rep(&quot;Star&quot;, 35))
  d &lt;- runif(n = 100, min = 0.5, max = 50)
  e &lt;- runif(n = 100, min = 0.5, max = 50)
  f &lt;- runif(n = 100, min = 0.1, max = 3)
  
  df &lt;- data.frame(&quot;Sample&quot;= a, &quot;Location&quot;=b, &quot;Obs&quot;=c, &quot;Measure1&quot;=d, &quot;Measure2&quot;=e, &quot;Measure3&quot;=f)
  
  # convert df to long format
  long &lt;- reshape2::melt(df, id.vars = c(&quot;Sample&quot;, &quot;Location&quot;, &quot;Obs&quot;), measure.vars = c(&quot;Measure1&quot;, &quot;Measure2&quot;, &quot;Measure3&quot;))
  
  # make a plot
  p &lt;- ggplot(long,aes(Location,value, color=Obs)) +
    facet_wrap(~ variable, drop=T, scale=&quot;free&quot;)+
    geom_boxplot(outlier.colour = NA, alpha=0.8, position = position_dodge2(width=1, preserve=&quot;single&quot;))+
    geom_point(size=1.2, aes(shape=Obs), position=position_dodge(width=0.7, preserve='total'))+
    scale_shape_manual(&quot;Obs&quot;, values = c(16,17,17,16,16),
                       labels = c(&quot;Sun&quot;, 
                                  &quot;Rain&quot;,
                                  &quot;Cloud&quot;,
                                  &quot;Thunder&quot;, 
                                  &quot;Star&quot;))+
    scale_color_manual(&quot;Obs&quot;, 
                       values=c(&quot;#00BF7D&quot;, &quot;#5B6BF7&quot;, &quot;#00B0F6&quot;, &quot;#A3A500&quot;, &quot;#F8766D&quot;),
                       labels = c(&quot;Sun&quot;, 
                                  &quot;Rain&quot;,
                                  &quot;Cloud&quot;,
                                  &quot;Thunder&quot;, 
                                  &quot;Star&quot;))+
    labs(x=&quot;Location&quot;, y = &quot;Measure&quot;)+
    theme(legend.text.align = 0)
  
  p
  </code></pre>
  <p>I get this :
  <a href="https://i.stack.imgur.com/k7sLA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/k7sLA.png" alt="enter image description here" /></a></p>
  <p>And I would like this :
  <a href="https://i.stack.imgur.com/c9Auo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/c9Auo.png" alt="enter image description here" /></a></p>
  <p>I tried with geom_signif() and stat_compare_means() functions but without success.
  Any idea please ?</p>
  <p>Thank you for your attention.</p>