Levelplot布局不工作R

Levelplot layout not working R

给定 levelplot objects 对于 point data,如何安排从 1 到 9 的地块,从 row 1 中的 1 开始,而不是我在图片中得到的以下?

# install.packages("gridExtra")
require(gridExtra) # also loads grid
require(lattice)
x <- seq(pi/4, 5 * pi, length.out = 100)
y <- seq(pi/4, 5 * pi, length.out = 100)
r <- as.vector(sqrt(outer(x^2, y^2, "+")))

grid <- expand.grid(x=x, y=y)
grid$z <- cos(r^2) * exp(-r/(pi^3))
plot1 <- levelplot(z~x*y, grid, cuts = 50, scales=list(log="e"), xlab="",
                   ylab="", main="Weird Function", sub="with log scales",
                   colorkey = FALSE, region = TRUE)

plot2 <- levelplot(z~x*y, grid, cuts = 50, scales=list(log="e"), xlab="",
                   ylab="", main="Weird Function", sub="with log scales",
                   colorkey = FALSE, region = TRUE)

plot3 <- levelplot(z~x*y, grid, cuts = 50, scales=list(log="e"), xlab="",
                   ylab="", main="Weird Function", sub="with log scales",
                   colorkey = FALSE, region = TRUE)

plot4 <- levelplot(z~x*y, grid, cuts = 50, scales=list(log="e"), xlab="",
                   ylab="", main="Weird Function", sub="with log scales",
                   colorkey = FALSE, region = TRUE)

plot5 <- levelplot(z~x*y, grid, cuts = 50, scales=list(log="e"), xlab="",
                   ylab="", main="Weird Function", sub="with log scales",
                   colorkey = FALSE, region = TRUE)

plot6 <- levelplot(z~x*y, grid, cuts = 50, scales=list(log="e"), xlab="",
                   ylab="", main="Weird Function", sub="with log scales",
                   colorkey = FALSE, region = TRUE)

plot7 <- levelplot(z~x*y, grid, cuts = 50, scales=list(log="e"), xlab="",
                   ylab="", main="Weird Function", sub="with log scales",
                   colorkey = FALSE, region = TRUE)

plot8 <- levelplot(z~x*y, grid, cuts = 50, scales=list(log="e"), xlab="",
                   ylab="", main="Weird Function", sub="with log scales",
                   colorkey = FALSE, region = TRUE)

plot9 <- levelplot(z~x*y, grid, cuts = 50, scales=list(log="e"), xlab="",
                   ylab="", main="Weird Function", sub="with log scales",
                   colorkey = FALSE, region = TRUE)


a <- c(plot1, plot2,plot3,plot4,plot5,plot6,plot7,plot8,plot9, layout = c(3, 3))

update(a,strip = strip.custom(factor.levels = c("1","2","3","4","5","6","7","8","9"),
       par.strip.text=list(cex=1.0),bg=list(col="gray95")))][1]][1]

试试这个:

a <- c(plot7,plot8,plot9,plot4,plot5,plot6,plot1,plot2,plot3, layout = c(3, 3))

update(a, strip = strip.custom(
    factor.levels = c("7","8","9","4","5","6","1","2","3"),
    par.strip.text=list(cex=1.0), bg=list(col="gray95")))