我正在观察两个治疗组(高脂或不高脂饮食)豚鼠的生物学数据,当我facet_wrap盒图和添加stat_compare_means (t.test)功能时,p值被切断。当我删除scales=“空闲”时,它仍然切断p值。我使用这个函数来移动措辞,但是由于所有的图都有不同的标度,例如在y=1,一个固定的值将强制所有的轴都是相同的。会喜欢任何指导的。
library(tidyverse)
library(ggforce)
library(ggpubr)
ex <- data.frame(hifat=rep(c('yes','no'),each=8),
treat=rep(rep(c('bmi','heart'),4),each=4),
value=rnorm(32) + rep(c(3,1,4,2),each=4))
ex %>%
ggplot(aes(x = hifat,
y = value)) +
geom_boxplot() +
geom_point() +
stat_compare_means(method = "t.test") +
facet_wrap(~ treat, scales = "free")
发布于 2022-03-09 00:55:35
解决了!感谢每一个提出建议的人,对我来说最有效的答案是将y轴的最大值扩大30%,以便给单词适当的空间。此外,从Jared学习position_nudge函数也是有效的。
ggplot(data = all_selected_long,
aes(x = hifat,
y = values)) +
geom_boxplot() +
geom_point() +
scale_y_continuous(expand = expansion(mult = .3)) +
stat_compare_means(method = "t.test") +
facet_wrap_paginate(~ measurement, scale = "free", ncol = 3, nrow = 3, page = 1)
https://stackoverflow.com/questions/71402836
复制相似问题