I am using {glue}
package to write expressions, which I then parse and display in ggplot2 annotations.
But, if I have a multiline expression, they are not vertically aligned. How can I achieve such an alignment? I thought atop + displaystyle
would do this, but it doesn't.
library(ggplot2)
library(glue)
b.text <- "bottom part of the expression"
t.text <- "top part of the expression"
ggplot() +
labs(subtitle = parse(text = glue("list(atop('{t.text}', '{b.text}'))")))