[R] changing point style in xyplots depending on groups

Gabor Grothendieck ggrothendieck at gmail.com
Fri Jul 10 13:16:36 CEST 2009


Try this:

xyplot(y ~ x, df, groups = gr, pch = c(1, 6, 16))


On Fri, Jul 10, 2009 at 6:03 AM, Thomas von
Känel<biotom at students.unibe.ch> 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.
>




More information about the R-help mailing list