How to plot grid plots on a same page?

后端 未结 2 1925
梦毁少年i
梦毁少年i 2020-12-18 13:19

I am using a package (treemap) that uses grid package to produce a treemap. However, I would like to plot several of these treemaps together, to ad

2条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-18 14:20

    Here's an approach that is very flexible for any grid graphics:

    vplayout <- function(x, y) viewport(layout.pos.row = x, layout.pos.col = y)
    grid.newpage()
    pushViewport(viewport(layout = grid.layout(1, 2)))
    print(a, vp = vplayout(1,1))
    print(b, vp = vplayout(1,2))
    

    Where a and b are your saved plot objects. So test each plot individually ahead of time, save them as a, b, ... then plot them as above.

    Oh, and if tmPlot always does grid.newpage then check to see if it has a has new.page argument which you can set to FALSE, or make a copy of the function and comment out the newpage.

提交回复
热议问题