33

How to print angstrom square in x axis? I tried as follows.

labs(x = "x axis" (Å^2)", y = "y axis")
Cœur
  • 34,719
  • 24
  • 185
  • 251
sara
  • 333
  • 1
  • 3
  • 5

2 Answers2

32

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()

enter image description here

akrun
  • 789,025
  • 32
  • 460
  • 575
25

You should use expression, preferable combined with paste, as follow:

ggplot(mtcars, aes(hp, mpg)) + geom_point() + labs(x = expression(paste("x axis ", ring(A)^2)), y = "y axis")

enter image description here

zyurnaidi
  • 1,993
  • 12
  • 14