# How to use latex characters in plots?

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

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!

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:

library(latex2exp)
library(tidyverse)

ggplot(mtcars, aes(mpg, hp)) +
geom_point() +
annotate(geom='text', label=TeX("$\\frac{\\sigma}{\\mu}exp(-\\pi \\phi)$"),
y=300, x=22, size=5) +
theme_bw()
#> Warning in is.na(x): is.na() 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.