plot_map_grid: Arrange Multiple tmap Plots in a Grid

View source: R/plot_maps.R

plot_map_gridR Documentation

Arrange Multiple tmap Plots in a Grid

Description

Arrange a list of tmap objects into a grid layout.

Usage

plot_map_grid(maps, ncol = 2)

Arguments

maps

A list of tmap objects.

ncol

Number of columns in the grid (default is 2).

Value

A tmap object representing arranged maps.

Examples


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)


mlspatial documentation built on Aug. 27, 2025, 1:09 a.m.