Search code examples
rggplot2exponentx-axis

How to add exponent value to x title


Having issue adding space, I am using the following to name my x and y title.

labs(y = "% biomass", x = expression(paste("Mulch amount", tha^{-1})))

It's resulting in no space between mulch amount and tha (making it Mulchamounttha(-1).

Does anyone know how to add space in between using the same code style?


Solution

  • From ?plotmath

    ‘x ~~ y’ put extra space between x and y

    plot(0:1, 0:1, xlab = expression("Mulch amount"~~tha^{-1}))
    

    Or you could include the space in your string

    plot(0:1, 0:1, xlab = expression("Mulch amount "*tha^{-1}))
    

    (since the * operator does juxtaposition, I often use it as a shortcut for paste())