问题
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?
回答1:
Try this instead:
+ labs(y = expression ("Acceleration in"~m/s^2))
来源:https://stackoverflow.com/questions/36920492/squared-superscript-in-ggplot2-yaxis-label-in-r