knitr::opts_chunk$set(echo = TRUE, fig.width = 9)
library(tmap)

Single map

# default: no panels
tm_shape(World) +
    tm_polygons("HPI")
# with
tm_shape(World) +
    tm_polygons("HPI") +
    tm_layout(panel.show = TRUE)

Facets defined with multiple variables

# default: with panels
tm_shape(World) +
    tm_polygons(c("HPI", "footprint"))
# without
tm_shape(World) +
    tm_polygons(c("HPI", "footprint")) +
    tm_layout(panel.show = FALSE)
# default: with panels
tm_shape(World) +
    tm_polygons("HPI") +
    tm_facets("continent")


### Facets defined with multiple variables, single pages


```r
# default: without
tm_shape(World) +
    tm_polygons(c("HPI", "footprint")) +
    tm_facets_pagewise()

```r
# with
tm_shape(World) +
    tm_polygons(c("HPI", "footprint")) +
    tm_facets_pagewise() +
    tm_layout(panel.show = TRUE)

Facets defined with 'by' variable

# default: with
tm_shape(World) +
    tm_polygons("HPI") +
    tm_facets("continent")
# without
tm_shape(World) +
    tm_polygons("HPI") +
    tm_facets("continent") +
    tm_layout(panel.show = FALSE)

Facet grid

# default: with panels
tm_shape(World) +
    tm_polygons("HPI") +
    tm_facets_grid("continent", "economy")
# without
tm_shape(World) +
    tm_polygons("HPI") +
    tm_facets_grid("continent", "economy") +
    tm_layout(panel.show = FALSE)


r-tmap/tmap documentation built on Feb. 28, 2025, 7:54 a.m.