On 4/16/08, Andreas Krause <[EMAIL PROTECTED]> wrote: > > Using xyplot, I am plotting observed versus predicted values conditional to > the values of a third variable. > I would thus like to have an aspect ratio of 1 and the same axis range. > Since the range of the values differs substantially between panels, the axis > ranges shall be different for each panel (along the lines of > relation="free"). However, x- and y-limits shall still be the same for a > given panel. > Any ideas on how to achieve that? > > # Example (that produces different x/y-limits per panel) > set.seed(3484) > x <- data.frame( > "x"=c(rnorm(10), rnorm(10, 10)) > ) > x$y <- x$x + rnorm(length(x$x)) > x$z <- c(rep(c("A", "B"), c(10, 10))) > > print(xyplot(y ~ x | z, data=x, > aspect=1, > scales=list( > relation="free" > ), > panel=function(x, y, ...) > { > panel.abline(0, 1) > panel.xyplot(x, y, ...) > } > ))
Try this: print(xyplot(y ~ x | z, data=x, aspect=1, scales=list( relation="free" ), prepanel = function(x, y, ...) { r <- range(x, y, ...) list(xlim = r, ylim = r) }, panel=function(x, y, ...) { panel.abline(0, 1) panel.xyplot(x, y, ...) } )) -Deepayan ______________________________________________ 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.