1

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]))
jay.sf
  • 60,139
  • 8
  • 53
  • 110

1 Answers1

1

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").

resulting plot with desired two-line axis label

Roland
  • 127,288
  • 10
  • 191
  • 288