Use layout function within levelplot

孤街醉人 提交于 2019-12-03 20:57:30

As suggested by @Pascal, you can use index.cond to do this:

For example:

library(rasterVis)
s <- stack(replicate(6, raster(matrix(runif(100), 10))))
levelplot(s, layout=c(3, 2), index.cond=list(c(1, 3, 5, 2, 4, 6)))

If you don't want to hard-code the list passed to index.cond, you can use something like:

index.cond=list(c(matrix(1:nlayers(s), ncol=2, byrow=TRUE)))

where the 2 indicates the number of rows you will have in your layout.


Of course you could also pass a stack with layers arranged in the desired row-wise plotting order, e.g.:

levelplot(s[[c(matrix(1:nlayers(s), ncol=2, byrow=TRUE))]], layout=c(3, 2))
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!