如何在ggplot2中使用上标 [英] How to use superscript with ggplot2

查看:1369
本文介绍了如何在ggplot2中使用上标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在x轴上打印埃方形?我尝试如下。我真的很抱歉我的简单问题。

How to print angstrom square in x axis? I tried as follows. I am really sorry for my simple question.

labs(x = "x axis" (Å^2)", y = "y axis")


推荐答案

我们可以使用 bquote

We can use bquote

library(ggplot2)
ggplot(mtcars, aes(hp, mpg)) + 
       geom_point() +
       labs(x = bquote('x axis'~(Å^2)), y = "y axis") +
       #or
       #labs(x = bquote('x axis'~(ring(A)^2)), y = "y axis") 
       theme_bw()

这篇关于如何在ggplot2中使用上标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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