This is a bit obscure but caused me some grief... R1.5.1/MS
Windows
There seems to be a peculiarity in legend associated with the use
of expression text. It seems as if expression text is used in (eg) an
mtext call then if the call to legend also includes expression text
and a subscript then the legend box and line spacing depends on
the value of cex used in the previous call to mtext, rather than that
specified in the call to legend.
An R file which demonstrates the problem is pasted below (subject
to the usual line wrapping issues)
Steve.
-------------------------------------------------------------------------------------
par(mfrow=c(2,2))
#Drawing a legend containing a subscript following a call to mtext
also containing expression text - the
# legend layout is dependent on the cex size specified in the
previous call to mtext
# (regardless of the size set in the call to legend).....
#This shows the issue...
for (i in 1:4)
{
plot(c(0,1),c(0,1),type="n",xaxt="n",yaxt="n",xlab="",ylab="")
#empty plot
mtext(expression(Expression~text),cex=i/2) #Some text in
margin - expression TEXT
legend(.5,.5,expression(Some[subscripted],Thing),lty=c(1,2),bty="o
",xjust=.5,yjust=.5,cex=1) #Draw legend with subscript in middle of
plot
}
#This does what it should
for (i in 1:4)
{
plot(c(0,1),c(0,1),type="n",xaxt="n",yaxt="n",xlab="",ylab="")
#empty plot
mtext("Normal Text",cex=i/2) #Some text in margin - normal
TEXT
legend(.5,.5,expression(Some[subscripted],Thing),lty=c(1,2),bty="o
",xjust=.5,yjust=.5,cex=1) #Draw legend with subscript in middle of
plot
}
#As does this
for (i in 1:4)
{
plot(c(0,1),c(0,1),type="n",xaxt="n",yaxt="n",xlab="",ylab="")
#empty plot
mtext(expression(Expression~text),cex=i/2) #Some text in
margin - expression TEXT
legend(.5,.5,expression(Some~unsubscripted,Thing),lty=c(1,2),bty"o",xjust=.5,yjust=.5,cex=1)
#Draw legend NO SUBSCRIPT in
middle of plot
}
#A second call to legend gets it right!
plot(c(0,1),c(0,1),type="n",xaxt="n",yaxt="n",xlab="",ylab="")
#empty plot
mtext(expression(Expression~text),cex=2) #Some text in
margin - expression TEXT
legend(.5,.5,expression(Some[subscripted],Thing),lty=c(1,2),bty="o
",xjust=.5,yjust=.5,cex=1) #Draw legend with subscript in middle of
plot
legend(.5,.5,expression(Some[subscripted],Thing),lty=c(1,2),bty="o
",xjust=.5,yjust=.5,cex=1) #Draw legend with subscript in middle of
plot
------------------------------------------------------------------------------------
Dr Steve Roberts
steve.roberts at man.ac.uk
Biostatistics Group,
School of Epidemiology and Health Sciences,
2nd Floor,Stopford Building,
University of Manchester.
M13 9PT.
0161 275 5192
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._