1
votes

I'm trying to create an interaction barplot with mean separation letters placed above each bar. I cannot figure out how to position labels so that they are dodged. Any help would be appreciated.

Here I'm using data based off the toothgrowth dataset:

df2 <- data.frame(supp=rep(c("VC", "OJ"), each=3),
              dose=rep(c("D0.5", "D1", "D2"),2),
              len=c(6.8, 15, 33, 4.2, 10, 29.5))
ggbarplot(df2, "dose", "len",color="supp",fill="supp", 
       label = c("bc","c","a","a","ab","bc"), position = position_dodge(.8))

enter image description here

1
Please provide some data so we can try to resolve the issue. A popular approach is reproducing the problem with built in data like diamonds, mtcars etc. - missuse
Sorry about that - small data set added. - David
Why not use bare ggplot instead of wrap up package ggpubr, especially when the plot is a simple barplot? See above link if it is works, then we can close this post. - zx8754
One of the aspects I like about ggpubr, which is not shown in the code above, is the ease in which I can place standard error bars. I know this can be done with ggplot, but I prefer ggpubr for its ease. - David

1 Answers

1
votes

Is this acceptable?

df2 <- data.frame(supp=rep(c("VC", "OJ"), each=3),
                  dose=rep(c("D0.5", "D1", "D2"),2),
                  len=c(6.8, 15, 33, 4.2, 10, 29.5),
                  label = c("bc","c","a","a","ab","bc"))

 ggbarplot(df2, "dose", "len",color="supp",fill="supp", label = "label",
               position = position_dodge(0.8), lab.col = "supp")

enter image description here