[R] quick legend() question

Robin Hankin r.hankin at noc.soton.ac.uk
Thu Mar 22 16:47:42 CET 2007


Hi

I have a scatterplot of points with pch=1 and a single point with  
pch=3, lwd=3.
It has a high line width to attract attention to it.

The following script



plot(rnorm(10),rnorm(10),col="black")
points(rnorm(10),rnorm(10),col="red")
points(0,0,pch=3,lwd=3)


if(TRUE){
   legend("bottomleft",c("a","b","Truth"),pch=c(1,1,3),col=c 
("black","red","black"))
} else {
   legend("bottomleft",c("a","b","Truth"),pch=c(1,1,3),col=c 
("black","red","black"),lwd=c(0,0,3))
}


doesn't quite work as desired:  the third symbol in the legend is not  
the right line width.

Replacing TRUE with FALSE doesn't work as desired either; the first two
symbols end up with a line I don't want.
The same happens with lwd=c(NA,NA,3).

How to coerce legend()   into doing what I want?




--
Robin Hankin
Uncertainty Analyst
National Oceanography Centre, Southampton
European Way, Southampton SO14 3ZH, UK
  tel  023-8059-7743



More information about the R-help mailing list