multiple (rasterVis) levelplots

前端 未结 1 1274
失恋的感觉
失恋的感觉 2020-12-31 18:15

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 =

相关标签:
1条回答
  • 2020-12-31 18:58

    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)
    

    enter image description here

    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))
    
    0 讨论(0)
提交回复
热议问题