Learn R Programming

tmap (version 3.3-3)

tmap_arrange: Arrange small multiples in grid layout

Description

Arrange small multiples in a grid layout. Normally, small multiples are created by specifying multiple variables for one aesthetic or by specifying the by argument (see tm_facets). This function can be used to arrange custom small multiples in a grid layout.

Usage

tmap_arrange(
  ...,
  ncol = NA,
  nrow = NA,
  widths = NA,
  heights = NA,
  sync = FALSE,
  asp = 0,
  outer.margins = 0.02
)

knit_print.tmap_arrange(x, ..., options = NULL)

# S3 method for tmap_arrange print(x, knit = FALSE, ..., options = NULL)

Arguments

...

tmap objects or one list of tmap objects. The number of multiples that can be plot is limited (see details).

ncol

number of columns

nrow

number of rows

widths

vector of column widths. It should add up to 1 and the length should be equal to ncol

heights

vector of row heights. It should add up to 1 and the length should be equal to nrow

sync

logical. Should the navigation in view mode (zooming and panning) be synchronized? By default FALSE.

asp

aspect ratio. The aspect ratio of each map. Normally, this is controlled by the asp argument from tm_layout (also a tmap option). This argument will overwrite it, unless set to NULL. The default value for asp is 0, which means that the aspect ratio is adjusted to the size of the device divided by the number of columns and rows. When asp is set to NA, which is also the default value for tm_layout, the aspect ratio will be adjusted to the used shapes.

outer.margins

outer.margins, numeric vector four or a single value. If defines the outer margins for each multiple. If will overwrite the outer.margins argument from tm_layout, unless set to NULL.

x

a tmap_arrange object (returned from tmap_arrange)

options

options passed on to knitprint

knit

should knit_print be enabled, or the normal print function?

Details

The global option tmap.limits controls the limit of the number of facets that are plotted. By default, tmap_options(tmap.limits=c(facets.view=4, facets.plot=64)). The maximum number of interactive facets is set to four since otherwise it may become very slow.

Examples

Run this code
if (FALSE) {
data(World)
w1 <- qtm(World, projection = "+proj=eck4", title="Eckert IV")
w2 <- qtm(World, projection = 3857, title="Mercator")
w3 <- qtm(World, projection = "+proj=gall", title="Gall stereographic")
w4 <- qtm(World, projection = "+proj=robin", title="Robinsin")

current.mode <- tmap_mode("plot")
tmap_arrange(w1, w2, w3, w4, widths = c(.25, .75))
tmap_mode(current.mode)
}

Run the code above in your browser using DataLab