How to include italics in a regression equation in text on plot in R


I am trying to include some model parameters on a plot in R using 'text' - here is an example:
text(x=1, y= 2, labels = y=a+bx)
I would like "y" and "x" to be in italics. Does anyone know how to do this?

I printed the text twice to ease the comparison between the italic and standard versions.

DF <- data.frame(x = 1:4, y = 1:4)
plot(DF$x, DF$y)
text(x = 1.2, y = 2, expression(paste(italic("y"), "= a", italic("x"), "+ b")))
text(x= 1.2, y = 2.5, "y = ax + b")

Created on 2020-05-09 by the reprex package (v0.3.0)

1 Like

Thanks a lot, boss again

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.