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

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

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))

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

扫码关注云+社区

领取腾讯云代金券