0

I have a question that is quite similar to another one: Using ggsignif with grouped bar graphs and facet_wrap not working

My question is: Is it possible to add a comparison line OVER the two facets? In this case: a comparison between S1 and S2, the facet variable Group?

This is the data and the plot of the other question:

dat <- data.frame(Group = c("S1", "S1", "S2", "S2"),
                  Sub   = c("A", "B", "A", "B"),
                  Value = c(3,5,7,8))

ggplot(dat, aes(Group, Value)) +
      geom_bar(aes(fill = Sub), stat="identity", position="dodge", width=.5) +
      facet_grid(~ Group, scales = "free")

What I want is a comparison line with geom_signif over the two facets (Variable Group with levels S1 and S2. Is this possible? If not, is there a way to do nearly the same but another way?

TobiSonne
  • 1,044
  • 7
  • 22
  • Please consider producing a [reproducible example](https://stackoverflow.com/q/5963269/1655567) demonstrating the problem, attempts and describing the desired outcome. – Konrad Jun 27 '20 at 13:45
  • Hi Tobi, it will be much easier to help if you provide at least a sample of your data with `dput()` or if your data is very large `dput([1:20,])`. Please also provide the code you are using to make your plot now so we can get an idea about what you are looking to create. It can also be helpful to mock up the desired result in paint or preview. You can [edit] your question and paste the output. Please surround the output with three backticks (```) for better formatting. See [How to make a reproducible example](https://stackoverflow.com/questions/5963269/) for more info. – Ian Campbell Jun 27 '20 at 15:07
  • I've updated the question. It was the data from the original question that provided a reproducible example. – TobiSonne Jun 27 '20 at 16:38
  • It's probably possible to do something very hacky. Can you include a sketch / mock-up of what your desired outcome looks like? I don't usually use `geom_signif`, & don't have a good sense of the calculations involved. – Z.Lin Jun 29 '20 at 08:25

0 Answers0