Learn R Programming

tmap (version 0.6)

tm_facets: Small multiples grid

Description

This element specifies how small multiples are placed in a grid. Either the argument by should be specified, i.e. the name of a variable by which the data is grouped, or multiple variable names sould be provided with tm_fill, tm_lines, or tm_bubbles. In this function, the number of rows and columns can be specified, as well as whether the scales are free (i.e. independent of each other).

Usage

tm_facets(by = NULL, ncol = NULL, nrow = NULL,
  free.scales = is.null(by), free.scales.fill = free.scales,
  free.scales.bubble.size = free.scales,
  free.scales.bubble.col = free.scales, free.scales.line.col = free.scales,
  free.scales.line.lwd = free.scales)

Arguments

by
data variable name by which the data is split
ncol
number of columns of the small multiples grid
nrow
number of rows of the small multiples grid
free.scales
logical. Should all scales of the plotted data variables be free, i.e. independent of each other? Possible data variables are color from tm_fill, color and size from
free.scales.fill
logical. Should the color scale for the choropleth be free?
free.scales.bubble.size
logical. Should the bubble size scale for the bubble map be free?
free.scales.bubble.col
logical. Should the color scale for the bubble map be free?
free.scales.line.col
Should the line color scale be free?
free.scales.line.lwd
Should the line width scale be free?

Value

See Also

../doc/tmap-nutshell.html{vignette("tmap-nutshell")}

Examples

Run this code
## World example
data(World)
tm_shape(World) +
    tm_fill(c("green", "blue")) +
tm_layout_World(c("A green world", "A blue world"))

## Europe example
data(Europe)
tm_shape(Europe) +
    tm_fill(c("gdp_cap_est", "pop_est_dens"), style="kmeans") +
tm_layout_Europe(c("GDP per capita", "Population density"), scale=2)



## Netherlands example
data(NLD_muni)
data(NLD_prov)

tm_shape(NLD_muni) +
    tm_fill(c("pop_0_14", "pop_15_24", "pop_25_44", "pop_45_64", "pop_65plus"),
            convert2density=TRUE, style="kmeans") +
tm_shape(NLD_prov) +
    tm_borders() +
    tm_facets(free.scales=FALSE) +
tm_layout_NLD(c("Population 0 to 14", "Population 15 to 24", "Population 25 to 44", 
    "Population 45 to 64", "Population 65 and older"), scale=4, draw.frame = TRUE)

Run the code above in your browser using DataLab