[R] How to draw different series for different groups in xyplot

Jie Liu jerryliu4u at gmail.com
Sun Mar 13 07:47:01 CET 2011


Hi guys,

I got a problem when I was trying to use lattice to do some plot. Below is
one working example which can generate one curve for A and one curve for B
in each subplot. However, I would like to just show the points for B, not
connecting the dots. As for A, I still want a curve (dots are connected). Is
there any people having any suggestions. Data are attached. Thanks a lot,

--Jerry

library(lattice)
example <- read.csv("example.txt",header=T)
xyplot(y~x1|as.factor(x2)*as.factor(x3), groups = as.factor(x4),
data=example, type="b", pch=c(16,4), col=c("blue","red"), xlim=c(1.04,1.26),
ylim = c(0,1.1), xlab = "X2", ylab = "Y",key = list(space = "top", text =
list("B"),  points = list(pch=16, col="blue", cex=0.8), text = list("A"),
points = list(pch=4, col="red", cex=0.8)) )
-------------- next part --------------
x1,y,x2,x3,x4
1.05,0.550707692,Prior=0.025,m=2,A
1.1,0.719302564,Prior=0.025,m=2,A
1.15,0.846502564,Prior=0.025,m=2,A
1.2,0.927158974,Prior=0.025,m=2,A
1.25,0.958974359,Prior=0.025,m=2,A
1.05,0.508789474,Prior=0.05,m=2,A
1.1,0.674368421,Prior=0.05,m=2,A
1.15,0.846136842,Prior=0.05,m=2,A
1.2,0.9362,Prior=0.05,m=2,A
1.25,0.973957895,Prior=0.05,m=2,A
1.05,0.539233333,Prior=0.1,m=2,A
1.1,0.697716667,Prior=0.1,m=2,A
1.15,0.831361111,Prior=0.1,m=2,A
1.2,0.914277778,Prior=0.1,m=2,A
1.25,0.956377778,Prior=0.1,m=2,A
1.05,0.550707692,Prior=0.025,m=5,A
1.1,0.719302564,Prior=0.025,m=5,A
1.15,0.846502564,Prior=0.025,m=5,A
1.2,0.927158974,Prior=0.025,m=5,A
1.25,0.958974359,Prior=0.025,m=5,A
1.05,0.508789474,Prior=0.05,m=5,A
1.1,0.674368421,Prior=0.05,m=5,A
1.15,0.846136842,Prior=0.05,m=5,A
1.2,0.9362,Prior=0.05,m=5,A
1.25,0.973957895,Prior=0.05,m=5,A
1.05,0.539233333,Prior=0.1,m=5,A
1.1,0.697716667,Prior=0.1,m=5,A
1.15,0.831361111,Prior=0.1,m=5,A
1.2,0.914277778,Prior=0.1,m=5,A
1.25,0.956377778,Prior=0.1,m=5,A
1.05,0.550707692,Prior=0.025,m=10,A
1.1,0.719302564,Prior=0.025,m=10,A
1.15,0.846502564,Prior=0.025,m=10,A
1.2,0.927158974,Prior=0.025,m=10,A
1.25,0.958974359,Prior=0.025,m=10,A
1.05,0.508789474,Prior=0.05,m=10,A
1.1,0.674368421,Prior=0.05,m=10,A
1.15,0.846136842,Prior=0.05,m=10,A
1.2,0.9362,Prior=0.05,m=10,A
1.25,0.973957895,Prior=0.05,m=10,A
1.05,0.539233333,Prior=0.1,m=10,A
1.1,0.697716667,Prior=0.1,m=10,A
1.15,0.831361111,Prior=0.1,m=10,A
1.2,0.914277778,Prior=0.1,m=10,A
1.25,0.956377778,Prior=0.1,m=10,A
1.05,0.719389744,Prior=0.025,m=2,B
1.1,0.760702564,Prior=0.025,m=2,B
1.15,0.792102564,Prior=0.025,m=2,B
1.2,0.811897436,Prior=0.025,m=2,B
1.25,0.819738462,Prior=0.025,m=2,B
1.05,0.764115789,Prior=0.05,m=2,B
1.1,0.806,Prior=0.05,m=2,B
1.15,0.849123684,Prior=0.05,m=2,B
1.2,0.870418421,Prior=0.05,m=2,B
1.25,0.879263158,Prior=0.05,m=2,B
1.05,0.776863889,Prior=0.1,m=2,B
1.1,0.813677778,Prior=0.1,m=2,B
1.15,0.844763889,Prior=0.1,m=2,B
1.2,0.863002778,Prior=0.1,m=2,B
1.25,0.872165278,Prior=0.1,m=2,B
1.05,0.890310564,Prior=0.025,m=5,B
1.1,0.896415179,Prior=0.025,m=5,B
1.15,0.901015795,Prior=0.025,m=5,B
1.2,0.903880205,Prior=0.025,m=5,B
1.25,0.904955897,Prior=0.025,m=5,B
1.05,0.907001684,Prior=0.05,m=5,B
1.1,0.913923789,Prior=0.05,m=5,B
1.15,0.921018947,Prior=0.05,m=5,B
1.2,0.923842105,Prior=0.05,m=5,B
1.25,0.924983158,Prior=0.05,m=5,B
1.05,0.926547778,Prior=0.1,m=5,B
1.1,0.930999778,Prior=0.1,m=5,B
1.15,0.934912222,Prior=0.1,m=5,B
1.2,0.936755778,Prior=0.1,m=5,B
1.25,0.937682889,Prior=0.1,m=5,B
1.05,0.931726359,Prior=0.025,m=10,B
1.1,0.933041641,Prior=0.025,m=10,B
1.15,0.934038564,Prior=0.025,m=10,B
1.2,0.934652513,Prior=0.025,m=10,B
1.25,0.934879179,Prior=0.025,m=10,B
1.05,0.962036316,Prior=0.05,m=10,B
1.1,0.963844421,Prior=0.05,m=10,B
1.15,0.965691684,Prior=0.05,m=10,B
1.2,0.966160211,Prior=0.05,m=10,B
1.25,0.966348842,Prior=0.05,m=10,B
1.05,0.983,Prior=0.1,m=10,B
1.1,0.9835,Prior=0.1,m=10,B
1.15,0.984,Prior=0.1,m=10,B
1.2,0.984,Prior=0.1,m=10,B
1.25,0.984,Prior=0.1,m=10,B


More information about the R-help mailing list