【问题标题】:Custom arranging tmap plots in R在 R 中自定义排列 tmap 图
【发布时间】:2021-10-19 10:57:28
【问题描述】:

我正在尝试排列使用 tmap 创建的地图,如下所示。我尝试使用下面的代码,但没有成功。

photo showing preferred arrange

map_plpot <-tmap_arrange(NULL,plot_1,NULL,plot_2,plot_2,plot_3,nrow = 2,ncol= 3)

【问题讨论】:

    标签: r ggplot2 tmap


    【解决方案1】:

    如果您想要更繁琐的解决方案,您可以使用gridgridExtra 包。这将使您可以将每个图形准确地放置在您想要的位置,只需花费一些工作就可以将它们放置在您需要的位置。

    # 1. Open png file
    png("plot_file.png", width = 20, height = 16, res = 300, units = "cm")
    
    grid.newpage()
    
    print(plot1, vp = viewport(0.5, 0.5) #x,y coordinates of the grid here
    print(plot2, vp = viewport(0.1, 0.1) #x,y coordinates of the grid here
    print(plot3, vp = viewport(0.3, 0.1) #x,y coordinates of the grid here
    print(plot4, vp = viewport(0.5, 0.1) #x,y coordinates of the grid here
    
    # 3. Close the file
    dev.off()
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-02-26
      • 2021-06-27
      • 2021-07-16
      • 1970-01-01
      • 1970-01-01
      • 2021-11-03
      • 2018-06-21
      • 1970-01-01
      相关资源
      最近更新 更多