const-ae/ggsignif

Customizing geom_signif with facet grid

reubebe opened this issue · 3 comments

I want to manually annotate the geom_signif but I want different annotations for the different facets i.e (visible and remembered). When I annotate and the "Visible facet" it duplicates under the "remembered facet. I want to do it separately. This is what I have so far (attached).

tgc <- structure(list(Group = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 2L, 
2L, 2L, 2L, 2L, 2L), .Label = c("Visible", "Remembered"), class = "factor"), 
    Condition = structure(c(1L, 1L, 2L, 2L, 3L, 3L, 1L, 1L, 2L, 
    2L, 3L, 3L), .Label = c("CEN", "IPS", "CTR"), class = "factor"), 
    test = structure(c(1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 
    1L, 2L), .Label = c("Pretest", "Posttest"), class = "factor"), 
    N = c(12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12), EE = c(7.33336873483333, 
    6.80361546108333, 7.09299323975, 7.85694358425, 7.03401583625, 
    6.98843623408333, 6.64690423166667, 6.76286593966667, 6.53229116175, 
    6.597801229, 5.87755052541667, 6.29406939166667), sd = c(1.10209636894719, 
    0.640166385925573, 0.829194321849813, 0.815786383997366, 
    1.13990647741682, 0.831699837406531, 0.894188346279884, 0.836594325568601, 
    0.762116322320573, 0.810426854086389, 0.986911196860133, 
    0.835898962602035), se = c(0.318147817642284, 0.18480011762014, 
    0.239367782465249, 0.235497244201055, 0.329062655793799, 
    0.240091062505814, 0.258129941215459, 0.241503979534773, 
    0.220004031922795, 0.233950081182639, 0.284896722586727, 
    0.241303245536807), ci = c(0.700238625346207, 0.406742316465117, 
    0.526844937010058, 0.518325939729, 0.724262022142493, 0.528436865645932, 
    0.568140169990552, 0.531546675059109, 0.484225609422399, 
    0.514920656885223, 0.62705345857213, 0.531104862508461)), row.names = c(NA, 
-12L), class = "data.frame")

ggplot(tgc, aes(x = Condition, y = EE)) +
  geom_bar(aes(fill = test), stat="identity", position=pos
![Rplot](https://user-images.githubusercontent.com/38767286/134897806-60eebf52-59df-4d57-9b2f-c4c31fd9291b.png)
ition_dodge(0.5), width=.5) +
  geom_signif(data = data.frame(Condition = c("CEN","IPS", "CTL")),
              aes(y_position=c(8.0, 8.0, 8.0, 8.0, 8.0, 8.0), xmin=c(0.8, 1.8, 2.8, 0.8, 1.8, 2.8), xmax=c(1.2, 2.2, 3.2, 1.2, 2.2,3.2),
                  annotations=c("**", "NS", "**", "NS", "**", "NS")), tip_length=0, manual = T) +
  scale_fill_manual(values = c("grey80", "grey20")) +
  facet_grid(~ Group, scales = "free")

Hey Reuben,

please take a look at the advanced example in the README.

Best,
Constantin

I read through and it wasn't very helpful, the problem I have is the overlap of the annotations, I got everything else figured out