首页
学习
活动
专区
圈层
工具
发布

R语言之可视化(24)生成带P值得箱线图

R语言之可视化(24)生成带P值得箱线图

代码语言:javascript
复制
rm(list=ls()) 
library(ggpubr)
data("ToothGrowth")

library(ggsci)
pal = pal_lancet("lanonc" )(9)


colors = pal_lancet("lanonc")(9)[ 1:3]


my_comparisons = list(c("0.5","1"),c("1","2"), c("0.5","2"))

p = ggboxplot( ToothGrowth , x = "dose", y = "len", color = "dose" , palette =colors,
               bxp.errorbar = T) +

stat_compare_means(comparisons = my_comparisons) +
stat_compare_means(method = "anova" , label.x = 1.7, label.y = 45)
p


p + stat_boxplot(geom ="errorbar", color = colors, width =0.4, size =1) +  

geom_boxplot(aes(color = dose))
下一篇
举报
领券