Discussion:
[R] ggplot - start axis label with superscript
Tom Walker
2014-10-14 09:34:21 UTC
Permalink
Dear help,

I?m stuck trying to begin an axis label in ggplot with a superscript. While I?m fine using expression to insert them in between normal text in an axis label, this doesn?t appear to work at the start of an expression. For example:

mydata <- data.frame(x = 1:10, y = 10:1)

# this works:
ggplot(mydata) +
aes(x = x, y = y) +
geom_line() +
ylab(expression(paste(Incorrect^{14}, "C", sep = "")))

# this doesn?t work (and is what I would like to be able to do):
ggplot(mydata) +
aes(x = x, y = y) +
geom_line() +
ylab(expression(paste(^{14}, "C", sep = "")))

Any help on this issue would be much appreciated!

Many thanks,

Tom
S Ellison
2014-10-14 11:34:00 UTC
Permalink
I'm stuck trying to begin an axis label in ggplot with a superscript.
For a crude work-round, you could try

ggplot(mydata) +
aes(x = x, y = y) +
geom_line() +
ylab(expression(paste(' '^{14}, "C", sep = "")))


S Ellison




*******************************************************************
This email and any attachments are confidential. Any use...{{dropped:8}}
Loading...