[R] expressions in legends

Robert Cunningham robut at forest.go.th
Sun Feb 3 09:50:56 CET 2002


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.

Cheers,


Robert Cunningham

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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