在ggpubr

时间:2017-09-20 16:22:00

标签: r ggplot2 ggpubr

我正在尝试创建一个交互条形图,在每个条形图上方放置平均分隔字母。我无法弄清楚如何定位标签以便它们被躲避。任何帮助将不胜感激。

这里我使用的是基于牙齿生长数据集的数据:

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 个答案:

答案 0 :(得分:1)

这可以接受吗?

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