[Rd] Re: [R] expressions in legends (PR#1302)

ligges@statistik.uni-dortmund.de ligges@statistik.uni-dortmund.de
Thu, 7 Feb 2002 19:15:14 +0100 (MET)

Robert Cunningham wrote:
> Dear R-users,
> A few days ago I met the problem of using text produced with
> expression() in legend() being elevated relative to text produced
> without the expression() so that the alignment with pch and lty is
> also messed up. After ferreting through the help I finally came across
> an answer, the adj argument of legend(). You can see and example of
> this in the Math expressions example section of ?legends. Of course,
> many users would, I am sure, overlook this option and 'put up' with
> the mis-aligned legend. I wonder why expression() causes this problem
> and whether anything can be done about it (other that the adj hack).
> For those unaware of the problem paste this example into your R.
> plot(1:10,1:10)
> legend(1,10,"Non expression_species",pch=21,lty=1,bty='n')
> legend(5,10,expression(italic("Expression species")),pch=21,lty=1,bty='n',col=2)
> legend(8.1,10,expression(italic("E. species")),pch=21,lty=1,bty='n',col=2,adj=c(0,0.6))
> The first legend key is ordinary text, the second expression(italic())
> with no adjustment, the third with the adjustment.

This looks like a bug, so moved to r-bugs.

Let's simplify your example:

 text(5, 10, "No expression ", adj=1)
 text(5, 10, expression(" expression"), adj=0)

So the bug is in text(), not in legend.
I'll try to investigate the problem later this day / week.

Uwe Ligges

r-devel 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-devel-request@stat.math.ethz.ch