This did the trick: panel.circ3 <- function(...) { args <- list(...) circ1 <- ellipse(diag(rep(1, 2)), t = 1) panel.xyplot(circ1[,1], circ1[,2], type = "l", lty = trellis.par.get("reference.line")$lty, col = trellis.par.get("reference.line")$col, lwd = trellis.par.get("reference.line")$lwd) circ2 <- ellipse(diag(rep(1, 2)), t = 2) panel.xyplot(circ2[,1], circ2[,2], type = "l", lty = trellis.par.get("reference.line")$lty, col = trellis.par.get("reference.line")$col, lwd = trellis.par.get("reference.line")$lwd) panel.xyplot(args$x, args$y, groups = args$groups, subscripts = args$subscripts) }
splom(~dat, groups = grps, lower.panel = panel.circ3, upper.panel = panel.circ3) Thanks, Max On Thu, Jan 20, 2011 at 11:13 AM, Peter Ehlers <ehl...@ucalgary.ca> wrote: > On 2011-01-19 20:15, Max Kuhn wrote: >> >> Hello everyone, >> >> I'm stumped. I'd like to create a scatterplot matrix with circular >> reference lines. Here is an example in 2d: >> >> library(ellipse) >> >> set.seed(1) >> dat<- matrix(rnorm(300), ncol = 3) >> colnames(dat)<- c("X1", "X2", "X3") >> dat<- as.data.frame(dat) >> grps<- factor(rep(letters[1:4], 25)) >> >> panel.circ<- function(x, y, ...) >> { >> circ1<- ellipse(diag(rep(1, 2)), t = 1) >> panel.xyplot(circ1[,1], circ1[,2], >> type = "l", >> lty = 2) >> circ2<- ellipse(diag(rep(1, 2)), t = 2) >> panel.xyplot(circ2[,1], circ2[,2], >> type = "l", >> lty = 2) >> panel.xyplot(x, y) >> } >> >> xyplot(X2 ~ X1, data = dat, >> panel = panel.circ, >> aspect = 1) >> >> I'd like to to the sample with splom, but with groups. >> >> My latest attempt: >> >> panel.circ2<- function(x, y, groups, ...) >> { >> circ1<- ellipse(diag(rep(1, 2)), t = 1) >> panel.xyplot(circ1[,1], circ1[,2], >> type = "l", >> lty = 2) >> circ2<- ellipse(diag(rep(1, 2)), t = 2) >> panel.xyplot(circ2[,1], circ2[,2], >> type = "l", >> lty = 2) >> panel.xyplot(x, y, type = "p", groups) >> } >> >> >> >> splom(~dat, >> panel = panel.superpose, >> panel.groups = panel.circ2) >> >> produces nothing but warnings: >> >>> warnings() >> >> Warning messages: >> 1: In is.na(x) : is.na() applied to non-(list or vector) of type 'NULL' >> >> It does not appear to me that panel.circ2 is even being called. >> >> Thanks, >> >> Max > > I don't see a function panel.groups() in lattice. > Does this do what you want or am I missing the point: > > splom(~dat|grps, panel = panel.circ2) > > Peter Ehlers > -- Max ______________________________________________ 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.