I there!
I want to include a label with subscript in geom_bracket
in ggplot2
. I tried in different ways, but no one worked (attempts in the comments):
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)))
)
What I got:
Subscript does not work.
Thanks
geom_bracket()
(which is from ggpubr
not ggplot2
) uses an argument to specify whether the label is an expression or text, so you can do:
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")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With