[R] changing point style in xyplots depending on groups

Paul Hiemstra p.hiemstra at geo.uu.nl
Fri Jul 10 12:53:53 CEST 2009


Thomas von Känel wrote:
> hi,
> i've got the following and would like to set the point style for A, B 
> and C myself (eg pch=1, 6 and 16)
>
> library(lattice)
> df <- data.frame(x  = log(c(1, 0.5 ,0.2 ,0.12 ,0.06, 1, 0.5 ,0.2, 
> 0.12,0.06, 1, 0.5 ,0.2 ,0.12,0.06)),
>        y  = c(1, 2, 5, 14, 24, 51, 50, 50, 49, 54, 100, 101, 103, 97, 
> 95),
>        gr = 
> c('A','A','A','A','A','B','B','B','B','B','C','C','C','C','C'))
> xyplot(df$y~df$x,groups=df$gr)
>
> thanks in advance for any help
> Tom von Känel
> Human Genetics
> Uni Berne
>
> ______________________________________________
> 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.
Making pch not one value but a list of numbers should work, in this case 
do not use the groups variable:

xyplot(x~y, df, pch = c(1,1,1,1,1,3,3,3,3,3,5,5,5,5,5))

cheers,
Paul

-- 
Drs. Paul Hiemstra
Department of Physical Geography
Faculty of Geosciences
University of Utrecht
Heidelberglaan 2
P.O. Box 80.115
3508 TC Utrecht
Phone:  +3130 274 3113 Mon-Tue
Phone:  +3130 253 5773 Wed-Fri
http://intamap.geo.uu.nl/~paul




More information about the R-help mailing list