在这里!
我想在geom_bracketin 中包含一个带下标的标签ggplot2。我尝试了不同的方式,但没有人成功(评论中的尝试):
library(ggplot2)
ggplot(data = mtcars, aes(x = vs, y = disp)) +
geom_point() +
geom_bracket(xmin = .25, xmax = .75, y.position = 250
,label = paste0("p_b<", format(0.06, nsmall = 3))
# ,label = paste0(expression(p[b]), "<", format(0.06, nsmall = 3))
# ,label = TeX(paste0("p_b<", format(0.06, nsmall = 3)))
)
Run Code Online (Sandbox Code Playgroud)
我得到了什么:
下标不起作用。
谢谢
geom_bracket()(来自ggpubrnot ggplot2)使用参数来指定标签是表达式还是文本,因此您可以执行以下操作:
library(ggplot2)
library(ggpubr)
ggplot(data = mtcars, aes(x = vs, y = disp)) +
geom_point() +
geom_bracket(xmin = .25, xmax = .75, y.position = 250,
label = "p[b] < 0.06", type = "expression")
Run Code Online (Sandbox Code Playgroud)