Open caijun opened 6 years ago
This can be resolved by specifying the output of TeX()
as character, although "character" is not one of the values that the output
argument can take, and turning the parse
argument in geom_text()
to TRUE. Like following code,
library(ggplot2)
library(latex2exp)
p <- ggplot(mtcars, aes(mpg, cyl)) +
geom_point() +
# labs(title = TeX("$\\theta$ = 270"))
geom_text(aes(x = 30, y = 7, label = TeX("$\\theta$ = 270", output = "character")),
parse = TRUE)
print(p)
This appears to be a new issue (for me) related to some change in ggplot2. The workaround above worked for me as documented. See stackoverflow question below. Thanks.
I would like to annotate math formulas on the plot using
geom_text()
and I specified the TeX expression to thelabel
argument in following code.However, it produces following error