【发布时间】: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)
【问题讨论】:
我正在尝试排列使用 tmap 创建的地图,如下所示。我尝试使用下面的代码,但没有成功。
photo showing preferred arrange
map_plpot <-tmap_arrange(NULL,plot_1,NULL,plot_2,plot_2,plot_3,nrow = 2,ncol= 3)
【问题讨论】:
如果您想要更繁琐的解决方案,您可以使用grid 和gridExtra 包。这将使您可以将每个图形准确地放置在您想要的位置,只需花费一些工作就可以将它们放置在您需要的位置。
# 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()
【讨论】: