Bex Bex - 3 months ago 34
LaTeX Question

Adding maths function in ggplot annotation

I have a density plot using ggplot and I have a mathematical function I want to add on the graph using +annotate() or something similar, but I am not sure how to do this.

The symbol I want in latex code is:

$f_{\epsilon}(|R_{i}|)$


Thanks for any help :)

Answer

try this,

# install.packages("latex2exp")

library(latex2exp)
test <- TeX("$f_{\\epsilon}(|R_{i}|)$")

library(grid)
grid.newpage()
grid.text(test, gp = gpar(cex=4))

enter image description here