How to use latex characters in plots?

I've been using RStudio for a short time and maybe this question is already answered but I'm struggling with it :sweat_smile:

I need to write latex characters in my plot, i.e. in the labs, for my graphics to look more professional, and i don't know how.

Thanks so much for your help!

Have a look at How can I include Greek letters in my plot labels? | R Code Fragments

1 Like

Thanks!! That's just what i was looking for!

The R plotmath expression system can be somewhat cumbersome to use. If you wish, you can directly include Latex in plots using the latex2exp package. For example:


ggplot(mtcars, aes(mpg, hp)) + 
  geom_point() + 
  annotate(geom='text', label=TeX("$\\frac{\\sigma}{\\mu}exp(-\\pi \\phi)$"), 
           y=300, x=22, size=5) +
#> Warning in applied to non-(list or vector) of type
#> 'expression'

Created on 2021-05-07 by the reprex package (v1.0.0)

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.