2

I'm trying to add a text in the form of ab to a graph instead of ab.

This works fine:

> xlab = expression(paste("a"^"b"))

If I reverse them I get:

Error: unexpected '^' in "xlab = expression(paste(^"

What would be the correct way to implement it?

Gimelist
  • 791
  • 1
  • 10
  • 25
  • 5
    `plot(1, xlab = expression(paste(""^"a", "b")))` or `plot(1, xlab = expression(''^a~b))` – user20650 Dec 19 '15 at 04:40
  • 1
    related question: [leading superscript in plotmath expression (w/ggplot2)](http://stackoverflow.com/questions/18111606/leading-superscript-in-plotmath-expression-w-ggplot2) – Jota Dec 19 '15 at 06:06

1 Answers1

4

Try phantom()

plot(0, xlab = ~ phantom() ^ a * b)

screenshot

G. Grothendieck
  • 254,981
  • 17
  • 203
  • 341