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

2019-05-20 10:25:56 浏览数 (1)

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

0 人点赞