【R語言】箱線圖統計檢驗線段長度

rm(list = ls())

data("iris")

library(ggplot2)
library(ggsignif)
library(ggsci)

comp_list = list(c('setosa','versicolor'),
                 c('setosa','virginica')) 

ggplot(iris, aes(Species, Sepal.Length, color = Species)) +
        geom_boxplot(width = 0.6) +
        geom_point(size = 1, alpha = 0.5) +
        geom_signif(comparisons = comp_list,
                    test = 'wilcox.test',
                    step_increase = 0.1,
                    map_signif_level = TRUE,
                    vjust = 0.5) +
        scale_x_discrete(limit = c('versicolor','setosa','virginica')) +
        scale_color_aaas() +
        theme_bw()+
        theme(legend.position = 'none')
ggplot(iris, aes(Species, Sepal.Length, color = Species)) +
        geom_boxplot(width = 0.6) +
        geom_point(size = 1, alpha = 0.5) +
        geom_signif(comparisons = comp_list,
                    test = 'wilcox.test',
                    step_increase = 0.1,
                    map_signif_level = TRUE,
                    vjust = 0.5,
                    y_position = c(8,8.5),
                    tip_length = c(0.1,0.25,
                                   0.7,0.1),
                    linetype = 'dashed',
                    color = 'black') +
        scale_x_discrete(limit = c('versicolor','setosa','virginica')) +
        scale_color_aaas() +
        theme_bw()+
        theme(legend.position = 'none')
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章