Hi R experts, I'm using the xyplot function in lattice to draw a multipanel plot consiting of 5x6 scatterplots. Now I need to link single points in each of those scatterplots (=panel),but the points, that need linking are different for each panel. I tried to use the panel.segments function for that, but I can't address each panel separately. Links right for panel 1, show up in all other panels, too. Tried functions like [panel.number()], but didn't work.
Would be so great, if somebody could help me with that! That's the code, I used: library(lattice) library(latticeExtra) #[...] attach(mydata) attach(links) #containing the coordinates for the segments fx, fy, tx, ty fx <- fx fy <- fy tx <- tx ty <- ty xyplot(LogN~LogM|factor(surber), par.settings = list(strip.background = list(col = "transparent")), xlab = "Log M", ylab = "Log N", layout = c(6,5), aspect = 1, as.table = TRUE, strip=FALSE, panel=function(x,y){ panel.xyplot(x,y,pch=20,col="black", bg="transparent") panel.fill(col = "transparent") panel.segments(fx,fy,tx,ty[panel.number()]) }) Also tried to split the data and loop it (but this code might be a bit messy. Apologies!) sn is the variable used to split according to panel. I just tried to do the links for 2 panel here: fx <- split(links$fx,links$sn) fy <- split(links$fy,links$sn) tx <- split(links$tx,links$sn) ty <- split(links$ty,links$sn) sn <- sn dothese <- c(1,2) ct <- 0 for (i in dothese){ ct <- ct + 1 x1 <- fx[[i]] y1 <- fy[[i]] x2 <- tx[[i]] y2 <- ty[[i]] } xyplot(LogN~LogM|factor(surber), par.settings = list(strip.background = list(col = "transparent")), xlab = "Log M", ylab = "Log N", layout = c(6,5), aspect = 1, as.table = TRUE, strip=FALSE, panel=function(x,y){ panel.xyplot(x,y,pch=20,col="black", bg="transparent") panel.fill(col = "transparent") panel.segments (x1,y1,x2,y2 [panel.number(1,2)]) }) Thanks, Doris -- View this message in context: http://r.789695.n4.nabble.com/lattice-xyplot-using-panel-segments-by-just-addressing-one-panel-tp2240248p2240248.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ 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.