[R] mathematical expression in legend

Arne Mueller mueller at cancer.org.uk
Wed Mar 13 02:31:43 CET 2002



On Wed, 13 Mar 2002, Paul Murrell wrote:

> Hi
> 
> 
> > I'm trying to put a mathematical expression into a legend, but R
> > complains about a syntax error. Basically i'd like to do this:
> >
> > legend.text = c(expression(x < 10), expression(x >= 10))
> 
> 
> The following works for me on 1.4.0 (yukky alignment which should be fixed
> in 1.4.1) ...

Hi,

yes, thanks, the stuff below does what I want. However, the legend text is
now shifted to the top relative to the symbols of the legend. This
probably what you mean with 'yukky' alignment? I'm running 1.4.1 :-(

>     plot(1:20, pch=rep(1:2, c(9, 11)))
>     legend(6, 4, c(expression(x < 10), expression(x >= 10)), pch=1:2)
> 
> 
> > The manual says that one can only pass mathematical expressions to axis,
> > text etc. but not to the legend command?
> 
> 
> Could you let us know where it says that -- sounds like it will need fixing.
> Thanks.

I found it under help('plotmath')

...
     If the `text' argument to one of the text-drawing functions
     (`text', `mtext', `axis') in R is an expression, the argument is
     interpreted as a mathematical expression and the output will be
     formatted according to TeX-like rules.  Expressions can also be
     used for titles, subtitles and x- and y-axis labels (but not for
     axis labels on `persp' plots).
...

it's probably just a misunderstanding, since it doesn't explicitely
include the legend funtion.

	thanks alot,

	Arne


> Paul
> 
> 
> 

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list