Different font families for text
To change the typeface used for plotted text, change the name of a font family. Standard values are family = "serif", "sans" (the default font), "mono", and "symbol", and the Hershey font families are also available. Some devices will ignore this setting completely. Text drawn onto the plotting region is controlled using par like this:
par(family="sans") text(5,8,"This is the default font") par(family="serif") text(5,6,"This is the serif font") par(family="mono") text(5,4,"This is the mono font") par(family="symbol") text(5,2,"This is the symbol font") par(family="sans")
Don't forget to turn the family back to "sans", otherwise you may get some very unexpected symbols in your next text. To write the results of calculations using text, it is necessary to use substitute with expression. Here, the coefficient of determination (cd) was calculated earlier and we want to write its value on the plot, labelled with ‘r2 =’:
cd<- 0.63 ... text(locator(1),as.expression(substitute(r^2 == cd,list(cd=cd))))
Just click when the cursor is where you want the text to appear. Note the use of ‘double equals’.

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access