I want to write this below text(LaTeX Code) in legend of the plot But I tried, I couldn't succeed. Any suggestion? R_2(\delta_{JS}(\bX,W),\theta)-R_2(\bX,W) R_2(\delta_{JS}(\bX,W),\theta)\R_2(\bX,W)
Thank you in advance.
I want to write this below text(LaTeX Code) in legend of the plot But I tried, I couldn't succeed. Any suggestion? R_2(\delta_{JS}(\bX,W),\theta)-R_2(\bX,W) R_2(\delta_{JS}(\bX,W),\theta)\R_2(\bX,W)
Thank you in advance.
The reason I did not agree with the vote to close is that now that the tikzDevice is missing in action, I do not know of an automatic way to do the translation to plotmath, so what follows in an inefficient hack that might provoke a much better answer if someone has a better way to generate Latex in R plots.
You should be able to use a plotmath equivalent in the labels argument to text(). My trouble was that I don't read LaTeX or TeX so I used: http://www.codecogs.com/latex/eqneditor.php to build something I could read. If there are other resources that I could have used I would be happy to hear of them. (My efforts to locate such resources took a fair amount of time and I kept wondering if I could have done better.)
So in R that is fairly complicated but I think doable:
?plotmath
plot(1,1)
text(1.1, 1.2, labels=expression(R[2]*( delta[JS]*(phantom(0)*","*W)*","* theta)-
R[2]*(phantom(0)*","*W)*R[2]*( delta[JS]*(phantom(0)*
","*W)*","* theta)[2](phantom(0)*","*W)) )
If you want italic:
text(1.1, 0.8, labels=expression( italic( R[2]*( delta[JS]*(phantom(0)*","*W)*","* theta)-
R[2]*(phantom(0)*","*W)*R[2]*( delta[JS]*(phantom(0)*
","*W)*","* theta)[2](phantom(0)*","*W)) ) )
And if you wanted serif fonts add this to the text arguments ,family="serif"
An example of adding expression to xlab of a plot (which is similar to adding LaTeX code I guess):
library(ggplot2)
data(cars)
qplot(speed, dist, data=cars) + xlab(expression(alpha + frac(beta, gamma)))