10

I am plotting a multiple line graph with ggplot2 and am having trouble labeling the y-axis with mile per second squared. I have tried the command:

ggplot(data.frame, aes(id)) + labs(y = "Acceleration in m/s^2")

and( after searching Stack Overflow):

ggplot(data.frame, aes(id)) + labs(y = expression ("Acceleration in m/s[2]")

In both cases, the label does not create superscript, instead looking exactly like "Acceleration m/s^2". How should this superscript command for a ggplot label be constructed?

coollikeabreeze
  • 103
  • 1
  • 1
  • 5

1 Answers1

16

Try this instead:

 + labs(y = expression ("Acceleration in"~m/s^2))
joran
  • 169,992
  • 32
  • 429
  • 468