如何将 ggplot stat_summary 几何设置为特定的 y 值?
How do I set ggplot stat_summary geometry to a specific y value?
我在折线图上显示了紧凑的字母,但我对组字母在不同高度的方式不满意。我想让它们都沿着特定的 y 值对齐。我该如何实现?
ggplot(data, aes(x = dose.log, y = positif.prop.total)) +
geom_point(color="grey", size=1) +
xlab(expression(log[10]~x+"0.001")) +
coord_cartesian(ylim=c(0,1)) +
ylab(" ") +
stat_summary(fun.y="mean", geom="point") +
stat_summary(fun.y="mean", geom="text", label=c("a", "a", "b", "c", "c"), size=5, vjust=-2) +
geom_smooth(method='lm', color="black", formula = y ~ poly(x,1)) +
stat_poly_eq(formula = my.formula, aes(label = paste(..eq.label.., ..rr.label.., sep = "~~~")), parse = TRUE) +
theme_bw() +
theme_pubr()
我找到了我正在寻找的解决方案。
stat_summary(fun.y="mean", geom="text", label=c("a", "a", "b", "c", "c"), size=5, mapping = aes(y = 0.75)) +
与之前的不同之处在于,我删除了 vjust
微调并将其替换为 mapping = aes(y = 0.75)
以指定我的 stat_summary
文本几何的确切 y 坐标:
我在折线图上显示了紧凑的字母,但我对组字母在不同高度的方式不满意。我想让它们都沿着特定的 y 值对齐。我该如何实现?
ggplot(data, aes(x = dose.log, y = positif.prop.total)) +
geom_point(color="grey", size=1) +
xlab(expression(log[10]~x+"0.001")) +
coord_cartesian(ylim=c(0,1)) +
ylab(" ") +
stat_summary(fun.y="mean", geom="point") +
stat_summary(fun.y="mean", geom="text", label=c("a", "a", "b", "c", "c"), size=5, vjust=-2) +
geom_smooth(method='lm', color="black", formula = y ~ poly(x,1)) +
stat_poly_eq(formula = my.formula, aes(label = paste(..eq.label.., ..rr.label.., sep = "~~~")), parse = TRUE) +
theme_bw() +
theme_pubr()
我找到了我正在寻找的解决方案。
stat_summary(fun.y="mean", geom="text", label=c("a", "a", "b", "c", "c"), size=5, mapping = aes(y = 0.75)) +
与之前的不同之处在于,我删除了 vjust
微调并将其替换为 mapping = aes(y = 0.75)
以指定我的 stat_summary
文本几何的确切 y 坐标: