[R] mfrow for levelplot?
Sundar Dorai-Raj
sundar.dorai-raj at pdf.com
Sat Jan 5 13:13:04 CET 2008
marcg said the following on 1/5/2008 3:48 AM:
> hello
>
> could anyone tell my, why I do not suceed with mfrow?
>
> par(mfrow=c(4,4))
>
> for (i in 5:17){
> levelplot(maxwater[,i]~maxwater$V1*maxwater$V2, col.regions=whiteblue(5), xlab="", cuts=4)
> }
>
> Thanks
>
> Marc
> --
>
Because "par" settings have little to no effect on lattice. From ?Lattice:
Lattice plots are highly customizable via user-modifiable
settings. However, these are completely unrelated to base graphics
settings; in particular, changing 'par()' settings usually have no
effect on lattice plots.
To do what you're doing, you need to understand how Lattice works with
panels. Try:
## Since you didn't supply the data.frame 'maxwater'
## here's a fake dataset to demonstrate
library(lattice)
set.seed(1)
z <- expand.grid(V1 = 1:10, V2 = 1:10)
z <- cbind(z, matrix(rnorm(100 * 16), 100, 16))
names(z) <- sprintf("V%d", 1:ncol(z))
## now create a formula
left <- paste(names(z)[3:18], collapse = "+")
right <- paste(names(z)[1:2], collapse = "*")
form <- formula(sprintf("%s~%s", left, right))
## not sure how you defined 'whiteblue', but here's my version
whiteblue <- colorRampPalette(c("white", "blue"))
## now call levelplot using a formula
levelplot(form, z, col.regions = whiteblue(5),
xlab = "", cuts = 4, as.table = TRUE)
In the future, please read the posting guide about providing "commented,
minimal, self-contained, reproducible code."
HTH,
--sundar
More information about the R-help
mailing list