9.8 Facets

Facets, also referred to as small multiples, enable the visualization of how spatial relationships change with respect to another variable, such as time.

urb_1970_2030 = urban_agglomerations |> 
  filter(year %in% c(1970, 1990, 2010, 2030))

tm_shape(world) +
  tm_polygons() +
  tm_shape(urb_1970_2030) +
  tm_symbols(col = "black", border.col = "white", size = "population_millions") +
  tm_facets(by = "year", nrow = 2, free.coords = FALSE) +
  tm_layout(legend.outside = TRUE,
            legend.outside.position = "bottom")