“平方" R中ggplot2 yaxis标签中的上标 [英] "Squared" superscript in ggplot2 yaxis label in R

查看:462
本文介绍了“平方" R中ggplot2 yaxis标签中的上标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用ggplot2绘制多线图,并且在用英里每秒平方标记y轴时遇到麻烦.我已经尝试过以下命令:

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(搜索堆栈溢出后):

and( after searching Stack Overflow):

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

在两种情况下,标签都不会创建上标,而是看起来完全像"Acceleration m/s ^ 2".应该如何构造用于ggplot标签的上标命令?

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?

推荐答案

尝试以下方法:

 + labs(y = expression ("Acceleration in"~m/s^2))

这篇关于“平方" R中ggplot2 yaxis标签中的上标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆