1

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

zx8754
  • 52,746
  • 12
  • 114
  • 209
David
  • 67
  • 2
  • 9
  • 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 Sep 20 '17 at 17:26
  • Sorry about that - small data set added. – David Sep 20 '17 at 23:59
  • Possible duplicate https://stackoverflow.com/questions/12018499/how-to-put-labels-over-geom-bar-for-each-bar-in-r-with-ggplot2 – zx8754 Sep 21 '17 at 07:37
  • 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 Sep 21 '17 at 07:38
  • 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 Sep 21 '17 at 12:58

1 Answers1

1

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

missuse
  • 19,056
  • 3
  • 25
  • 47