KevCaz's Website

It is rather straightforward to add mathematical annotation in a plot with R. However, I have noted that people struggle with the two following :

  1. combining mathematical expression and text;
  2. using variables’ values within an expression.

The first one is actually easy, you just need to add and quotation marks to add text in expression and to use * to concatenate elements.

1
2
plot(c(0,1), c(0,1), type = "n")
text(0.5, .5, labels = expression(delta == "cool"+2+italic("super")*bold("cool")+3+beta), cex = 3)

For the second problem, one should use either bquote or substitute (check out the documentation of these function) as explained on . Below is an example using text, text format and variables:

1
2
3
4
delta <- 10
plot(c(0,1), c(0,1), type = "n")
text(0.5, .75, labels = bquote(beta^j == .(delta)+bold("h")), cex = 4)
text(0.5, .25, labels = substitute(alpha[i] == a + b, list(a = 10)), cex = 4)