Thomas von Känel
2009-Jul-10 10:03 UTC
[R] changing point style in xyplots depending on groups
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
Paul Hiemstra
2009-Jul-10 10:53 UTC
[R] changing point style in xyplots depending on groups
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
Gabor Grothendieck
2009-Jul-10 11:16 UTC
[R] changing point style in xyplots depending on groups
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. >