Reputation: 13
How to write subscripts was already nicely described in this post: Subscripts in plots in R
They also tackled more complex problems, e.g.:
plot(1:10, xlab = expression('hi'[5]*'there'[6]^8*'you'[2]))
The question: how to write this in two lines? Using \n
(Line Feed) causes a strange problem of reordering:
plot(1:10, xlab = expression('hi'[5]*'there'[6]^8*'you \n awesome people'[2]))
Upvotes: 1
Views: 29
Reputation: 132576
You cannot mix plotmath expressions with "\n"
. However, you can use the plotmath command atop
:
opar <- par(no.readonly = TRUE)
par(mar = c(7, 4, 4, 2) + 0.1,
mgp = c(5, 1, 0))
plot(1:10, xlab=expression(atop('hi'[5] * 'there'[6]^8 * 'you', 'awesome people'[2])))
par(opar)
Note how I added *
to juxtapose different texts. Your attempt was not valid syntax. You should study help("plotmath")
.
Upvotes: 1