我正在使用mtcars
数据集运行条形图,添加统计数据以进行组比较。使用下面的代码,我得到了与 ** 的统计比较
ggbarplot(
mtcars, x = "am", y = "mpg",
add = "mean_sd",fill = "black",
xlab = "AM",
ylab="Fuel consumption (Miles/ Gallon)"
) +
stat_compare_means(
comparisons = list(c("0", "1")),
label = "p.signif"
) + scale_x_discrete(labels= c(0,1))
但是,我想调整 ylim。当我运行下面的代码时,统计比较丢失了(我猜是移出视图)。无论如何调整 ylim 并保持统计数据
ggbarplot(
mtcars, x = "am", y = "mpg",
add = "mean_sd",fill = "black",
xlab = "AM",
ylab="Fuel consumption (Miles/ Gallon)",ylim=c(0,30)
) +
stat_compare_means(
comparisons = list(c("0", "1")),
label = "p.signif"
) + scale_x_discrete(labels= c(0,1))