Try this: Key <- list(text = list(c("FDP", "FDL")), points = list(pch = c("*", "o"), col = c("red", "blue"), cex = 2), space = "right")
xyplot(S ~ t | ID, key = Key, panel = function(...) { panel.points(..., col = rep(c("red", "blue"), 3:4), pch = rep(c("*", "o"), 3:4), cex = 2) panel.lines(..., col = 1, lty = 2) }) On Wed, Jul 1, 2009 at 2:12 AM, jlfmssm<jlfm...@gmail.com> wrote: > I have a data set like this > > > ID=c("A","A","A","A","A","A","A","B","B","B","B","B","B","B") > s=c(1.1,2.2,1.3,1.1,3.1,4.1,4.2,1.1,2.2,1.3,1.1,3.1,4.1,4.2) > d=c(1,2,3,4,5,6,7,1,2,3,4,5,6,7) > t=c(-3,-2,-1,0,1,2,3,-3,-2,-1,0,1,2,3) > > mydata<-data.frame(cbind(as.character(ID),as.numeric(s),as.integer(d),as.numeric(t))) > colnames(mydata)=c("ID","S","d","t") > > I want to use xyplot in lattice to draw a plot using the following code: > > attach(mydata) > library(lattice) > > xyplot(S~t|ID,type="b") > > Now I want to label the line from -3 to -1 with one type( for example, > red with "*") , the line from 0 to 3 with another type(blue with"o"), > and give text label says: red "*"="FDP", blue"o"="FDL" > > Does anyone know how to do this? > > thanks, > > jlfmssm > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@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. > ______________________________________________ R-help@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.