[R] Greek letters in plots

Marc Schwartz MSchwartz at mn.rr.com
Tue Nov 1 14:54:20 CET 2005


On Tue, 2005-11-01 at 05:20 -0800, Johanna Hardin wrote:
> Hi, all.  I know that this is probably something that others have asked,
> but I can't find a reference in either the FAQ or the help pages.
> 
> I'm trying to find a way to put Greek letters as a label of the plot
> *with* a value from the data.  Previously I've used pasted and the word
> "rho".
>
> *      paste("rho=", cor2[i])
> 
> will produce a label of "rho=0.74", or whatever.  But if I use
> 'substitute' or 'evaluate' commands in order to get a real Greek letter,
> I lose the ability to paste it with a data value.

> Any ideas?

> Thanks, Jo

Try this:

  cor2 <- 0.74
  plot(1:5)
  title(bquote(rho == .(cor2)))

See ?plotmath and ?bquote for more information, noting the use of
the .(Variable) syntax for variable substitution.

HTH,

Marc Schwartz




More information about the R-help mailing list