[R] How do I get a character and a symbol in a legend

Henrique Dallazuanna wwwhsd at gmail.com
Wed Jan 23 19:04:40 CET 2008


Try:

plot(1:10,1:10,type="n")
points(6:10,6:10,pch=20)
points(1:5,1:5,pch=3)
legend(5,5, c("A","B"), pch=c(3,20))


On 23/01/2008, steve <fisk at bowdoin.edu> wrote:
> In the following snippet
>
> plot(1:10,1:10,type="n")
> points(1:5,1:5,pch="+")
> points(6:10,6:10,pch=20)
> legend(5,5, c("A","B"), pch=c("+",20))
>
> I want to get a legend with a "+" and a solid circle (pch=20).
> However, what I get in the legend is "+" and "2". How can I get a "+"
> and a solid circle?
>
> thanks,  Steve
>
>  > sessionInfo()
> R version 2.6.1 (2007-11-26)
> i686-pc-linux-gnu
>
> locale:
> LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=en_US.UTF-8;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C
>
> attached base packages:
> [1] stats     graphics  grDevices datasets  utils     methods   base
>
> loaded via a namespace (and not attached):
> [1] rcompgen_0.1-17
>
> ______________________________________________
> R-help at r-project.org 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.
>


-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O



More information about the R-help mailing list