[R] legend, "lheight", and alignment

emorway emorway at usgs.gov
Thu Dec 1 17:54:42 CET 2011


Hello,

A bit of fairly simple code, yet I don't seem to be able to manipulate it
quite as much as I would like:

1)  It would be nice if the objects appearing in the legend were aligned,
and by aligned I mean the boxes are centered over the lines.  Do I need to
adjust the use of "NA" in the code below to accomplish this?  Here's how it
appears on my machine:

http://r.789695.n4.nabble.com/file/n4129402/example.png 

2)  Because I'm using a call to 'expression' in the text contained in the
legend, it would be nice to space  the lines of text a bit more.  My feeble
attempt was to increase the lheight parameter in the hopes this would affect
the legend...to no avail.  Further, lheight cannot be added to the argument
list of legend.  I've been unable to track down another parameter applicable
to legend, suggestions very much appreciated.

par(lheight=2)
plot(1,1,col="white")

legend("center", legend=c(expression(paste("Observed
",italic(bar(EC)[e]))),expression(paste("Simulated
",italic(bar(EC)[e]))),"test1","test2"),
       lty = c(NA,NA,1,1),
       col = c("black","black","red","blue"), 
       density = c(NA,25,NA,NA),
       border=c("black","black",NA,NA),
       fill = c("grey","black",NA,NA), 
       angle = c(NA,45,NA,NA),
       cex = 1.25, bty = "n", xpd = TRUE)


> sessionInfo()
R version 2.13.2 (2011-09-30)
Platform: x86_64-pc-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=English_United States.1252 
[2] LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] tools_2.13.2
> 


--
View this message in context: http://r.789695.n4.nabble.com/legend-lheight-and-alignment-tp4129402p4129402.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list