我对这种图表有个问题。我不知道是否有人可以建议一些教程/网站页面/问题堆栈溢出可以显示如何将有可能创建这种图形,特别是,我感兴趣的是如何获得/显示相同的彩色框周围的斑点。先谢了
wj8zmpe11#
OP要求的更新:
代码:
library(ggpubr) # create fake data mtcars1 mtcars1 <- mtcars %>% add_row(mtcars[1,]) %>% mutate(group = rep(c("A", "B", "C"), 11)) compare_means(disp ~ cyl, data = mtcars1, method = "t.test") my_comparisons <- list( c("4", "6"), c("6", "8"), c("4", "8") ) ggboxplot(mtcars1, x = "cyl", y = "disp", fill = "cyl", add = "jitter") + scale_fill_manual(values=c("#0433ff", "#fe403f", "#66cd00")) + stat_compare_means(comparisons = my_comparisons)+ stat_compare_means(label.y = 700) + facet_grid(.~group, switch = "x")+ xlab(NULL) + theme(strip.background = element_blank(), strip.placement = "outside")
下面是使用ggpubr包和mtcars数据集的示例:
ggpubr
mtcars
library(ggpubr) compare_means(disp ~ cyl, data = mtcars, method = "t.test") my_comparisons <- list( c("4", "6"), c("6", "8"), c("4", "8") ) ggboxplot(mtcars, x = "cyl", y = "disp", color = "cyl", add = "jitter") + stat_compare_means(comparisons = my_comparisons)+ stat_compare_means(label.y = 700)
1条答案
按热度按时间wj8zmpe11#
OP要求的更新:
代码:
下面是使用
ggpubr
包和mtcars
数据集的示例: