I am doing mapping in R and found the very useful levelplot
function in rasterVis
package. I will like to display multiple plots in a window. However, par(mfcol)
does not fit within lattice
. I found layout
function very useful in my case but it fails to perform what I want to do.
Here is my code:
s <- stack(Precip_DJF1, Precip_DJF2, Precip_DJF3, Precip_DJF4,
Precip_DJF5, Precip_DJF6)
levelplot(s, layout(matrix(c(1, 2, 0, 3, 4, 5), 2, 3)),
at=seq(floor(3.81393), ceiling(23.06363), length.out=20),
par.settings=themes, par.strip.text=list(cex=0),
scales=list(alternating=FALSE))
Using
layout(matrix(c(1, 2, 0, 3, 4, 5), 2, 3))
fails while layout(3, 2)
works but the plots are displayed row-wise instead of column-wise. I want the plots to be displayed in column 1, then column 2 etc. Something like:
mat <- matrix(c(1, 2, 3, 4, 5, 6), 2, 3)
> mat
# [,1] [,2] [,3]
# [1,] 1 3 5
# [2,] 2 4 6
Is there a function within levelplot
or lattice
to do this kind of layout?
Thanks in advance.