【发布时间】:2021-02-09 10:49:37
【问题描述】:
我无法正确放置此图的标签。 “正确”是指不在顶部卡住或重叠,而是沿 y 轴向下移动到适当的位置。请参阅下面的可重现示例和图表。当前的标记方法意味着忽略 y 轴位置。我该如何解决这个问题?
library(magrittr)
library(dplyr)
library(ggpubr)
set.seed(20)
col1<-c(rep('E', each = 8))
col2<-c(rep('R', each = 8))
col3<-c(rep('S', each = 8))
behaviour<-c(col1,col2,col3)
value <- runif(length(behaviour), min=0, max=0.0006)
species <- c(rep('B_theta', each = length(behaviour)))
test.data <- data.frame(behaviour, value, species)
d <- compare_means(value~behaviour, data = test.data,method = 't.test')
d %<>% mutate(y_pos = c(1.004,1.156763e-06,5.882128e-04),labels = ifelse(p<0.15,p.format,p.signif))
d
.y. group1 group2 p p.adj p.format p.signif method y_pos labels
value E R 0.4678791 0.76 0.47 ns T-test 1.004000e+00 ns
value E S 0.1559682 0.47 0.16 ns T-test 1.156763e-06 0.16
value R S 0.3794209 0.76 0.38 ns T-test 5.882128e-04 ns
ggplot(data=subset(test.data, !is.na(value)), aes(x=behaviour,y=value)) +
geom_boxplot(aes(fill = behaviour), width=0.4,outlier.colour = "transparent")+
geom_point(aes(fill = behaviour), size = 5, shape = 21, position = position_jitterdodge()) +
scale_fill_manual(values = c("E" = '#3797a4', "R"= '#96bb7c',"S"= '#944e6c'))+
theme_classic()+
scale_y_log10() + annotation_logticks(sides = "l")+
geom_signif(data = as.data.frame(d), textsize=6, tip_length = 0.01,
aes(xmin=group1, xmax=group2, annotations=labels,y_position=y_pos),manual=TRUE)
Warning message:
"Ignoring unknown aesthetics: xmin, xmax, annotations, y_position"
理想的输出:
【问题讨论】:
-
geom_siginif 函数从何而来?您能否将必要的软件包添加到您的 MRE 中?
-
嗨,我已将库添加到编辑中。谢谢