将指数添加到轴标签(R / ggplot2)

时间:2021-01-27 14:58:19

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?

我是R和ggplot2的新手,所以慢慢说;)有没有人有任何建议?

2 个解决方案

#1


2  

expressionshould be added to labs(x =

表达式应该添加到实验室(x =

 x = expression(paste("Volume ", m^{3})), y = expression(paste("Volume ", m^{3}))

#2


0  

you can use parse

你可以使用解析

labs(x=parse(text='Volume, m^3'), y=parse(text='Volume, m^3'))

#1


2  

expressionshould be added to labs(x =

表达式应该添加到实验室(x =

 x = expression(paste("Volume ", m^{3})), y = expression(paste("Volume ", m^{3}))

#2


0  

you can use parse

你可以使用解析

labs(x=parse(text='Volume, m^3'), y=parse(text='Volume, m^3'))