Quantcast
Channel: Subscript letters in ggplot axis label - Stack Overflow
Viewing all articles
Browse latest Browse all 3

Subscript letters in ggplot axis label

$
0
0

I'm trying to work out how to have subscript letters in an axis label.

dat <- data.frame(x = rnorm(100), y = rnorm(100))ggplot(dat, aes(x=x,y=y)) +    geom_point() +    labs(y=expression(Blah[1]))dat <- data.frame(x = rnorm(100), y = rnorm(100))ggplot(dat, aes(x=x,y=y)) +    geom_point() +    labs(y=expression(Blah[1d]))

The first example works as it's just a number, as soon as you have a character in the square brackets, it fails. Blah[subscript(1d)] is essentially what I need, but I can't work out how to get it to let me have letters in subscript. I have tried variations, including paste().

The following examples provide strange behavior:

labs(y=expression(Blah[12])) # this workslabs(y=expression(Blah[d])) # this workslabs(y=expression(Blah[d1])) # this workslabs(y=expression(Blah[1d])) # this fails

Thoughts?


Viewing all articles
Browse latest Browse all 3

Trending Articles





<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>