3

I've looked at a number of the solutions to the same question but applied to different datasets, and none seem to work for me.

I'm looking to add metres cubed as the unit for each axis title, with metres cubed obviously showing with an exponent. The latest code I tried (which didn't work) was as follows:

ggplot(data=vol30, aes(x=control, y=vol30)) + geom_point(alpha=.6, size=4, color="#880011") + ggtitle("Ground Survey vs. 30m UAV Survey") + labs(x="Volume, m^{3}", y="Volume, m^{3}") + xlim(0, 5) + ylim(0, 5) + geom_abline(intercept = 0, slope = 1, alpha=.6, size = 1, colour="blue")

I'm new to R and ggplot2, so speak slowly ;) Does anyone have any recommendations?

Luke
  • 35
  • 1
  • 1
  • 4
  • Possible duplicate of [how to write micrometer squared per cubic meter in plot label in R](http://stackoverflow.com/questions/9269607/how-to-write-micrometer-squared-per-cubic-meter-in-plot-label-in-r) – Mateusz1981 Oct 15 '15 at 13:20

2 Answers2

9

expressionshould be added to labs(x =

 x = expression(paste("Volume ", m^{3})), y = expression(paste("Volume ", m^{3}))
Mateusz1981
  • 1,817
  • 17
  • 33
1

you can use parse

labs(x=parse(text='Volume, m^3'), y=parse(text='Volume, m^3'))
cccmir
  • 953
  • 6
  • 12