[R] quick legend() question

Gabor Grothendieck ggrothendieck at gmail.com
Thu Mar 22 17:27:38 CET 2007


Try pt.lwd= instead of lwd= in your legend call.

On 3/22/07, Robin Hankin <r.hankin at noc.soton.ac.uk> wrote:
> 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
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list