Gimelist
Gimelist

Reputation: 823

Adding superscript to graph in R with no preceding character

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?

Upvotes: 2

Views: 105

Answers (1)

G. Grothendieck
G. Grothendieck

Reputation: 269586

Try phantom()

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

screenshot

Upvotes: 4

Related Questions