0

I'm using ggplot2 to plot a chart. I want to add an exponent to a text within the Y-axis title, so it would look like this:

Energy (kcal ∙ mol-1)

I usually write the axis title text inside labs () and its aesthetic inside theme (axis.title.y = element_text ()). I've seen this answer, but I couldn't understand any of it...

Gerald T
  • 704
  • 3
  • 18
ginn
  • 87
  • 5

1 Answers1

2

Probably a duplicate question. Check this question for detailed answers.

You can build an expression

ggplot() + geom_point(aes(x=1, y=1)) + 
  labs(y=expression('Energy (kcal '~mol^-1*')'))

plot

Gerald T
  • 704
  • 3
  • 18
  • Also, for future reference: when you use `expression ()` inside `labs ()`, the font face of your axis title won't show in bold even if you specify it in `theme (axis.title.y = element_text ())` . You'll actually have to specify it inside `expression ()` like this: `labs (y = expression (bold ("Energy (kcal ∙ mol"^-1*")")))` – ginn May 31 '23 at 18:05