I am trying to place one word over another for a title. I mean literally over, not just a 'divides by' sign one value over another (or word) to save space. It is supposed to mean divides by and there needs to be a line.
I cannot find how to do this, can you help?
Thanks,
Chris
You can create fractions in a title with frac()
:
p <- ggplot(mtcars, aes(x = mpg, y = disp)) + geom_point()
p + ggtitle(expression(paste("This is a fraction: ", frac(foo, bar))))
Note that the whole title must be put inside expression()
. Alternatively, you can also use over()
to do the same. The following example also shows that you can create other mathematical expressions in a similar fashion:
p + ggtitle(expression(paste("This is a fraction: ", over(3 * alpha, sum(b[i], i==1, N)))))
For more information, read ?plotmath
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With