plot_map_grid | R Documentation |
Arrange a list of tmap objects into a grid layout.
plot_map_grid(maps, ncol = 2)
maps |
A list of tmap objects. |
ncol |
Number of columns in the grid (default is 2). |
A tmap object representing arranged maps.
library(sf)
library(tmap)
# Load sample spatial data
nc <- st_read(system.file("shape/nc.shp", package = "sf"), quiet = TRUE)
# Add mock variables to map
nc$var1 <- runif(nrow(nc), 0, 100)
nc$var2 <- runif(nrow(nc), 10, 200)
# Create individual maps
map1 <- tm_shape(nc) + tm_fill("var1", title = "Variable 1")
map2 <- tm_shape(nc) + tm_fill("var2", title = "Variable 2")
# Arrange the maps in a grid using your function
plot_map_grid(list(map1, map2), ncol = 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.