i\'m quite desperate trying to adjust two levelplots of one rasterstack each on one plot. It seems like rasterVis::levelplot
does not take the par(mfrow =
For grid-based graphics, including those produced by lattice (which underlies rasterVis' plotting functions) the gridExtra function grid.arrange()
does +/- the same thing as par(mfcol=)
does for base R graphics.
library(gridExtra)
p1 <- levelplot(r1)
p2 <- levelplot(r2)
grid.arrange(p1, p2, ncol=2)
Edit: An alternative lattice-specific solution uses the split=
argument to print.trellis()
, the plotting method for lattice plots (h.t. baptiste & Oscar Perpiñán). split=
takes a vector of four numbers. The vector's 3rd and 4th elements give the number of columns and rows in the display, while its 1st and 2nd elements give the column- and row-positions of the object being printed.
library(gridExtra)
p1 <- levelplot(r1)
p2 <- levelplot(r2)
print(p1, split=c(1,1,2,1), more=TRUE)
print(p2, split=c(2,1,2,1))