How to plot grid plots on a same page?

后端 未结 2 1922
梦毁少年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:08

    Thanks for your question. The output of tmPlot is indeed not a saved plot.

    In the next update I will add argument vp, by which a viewport can be specified to draw in. Only if it is not specified, grid.newpage is called.

    UPDATE: You could check and test the development version at https://github.com/mtennekes/treemap

    To apply the example of Bryan Hanson:

    vplayout <- function(x, y) viewport(layout.pos.row = x, layout.pos.col = y)
    grid.newpage()
    pushViewport(viewport(layout = grid.layout(1, 2)))
    tmPlot(GNI2010,
      index="continent",
      vSize="population",
      vColor="GNI",
      type="value",
      vp = vplayout(1,1))
    tmPlot(GNI2010,
      index=c("continent", "iso3"),
      vSize="population",
      vColor="GNI",
      type="value",
      vp = vplayout(1,2))
    

提交回复
热议问题