Specify facets. tm_facets()
is the core function, but recommended is to use
tm_facets_wrap()
, tm_facets_stack()
or tm_facets_grid()
.
The former two specify facets for one grouping variable (so one faceting dimension).
The difference is that wrap may place facets in multiple rows and columns whereas
tm_facets_stack()
stacks the facets either horizontally or vertically.
tm_facets_grid()
supports up to three faceting dimensions.
Usage
tm_facets(
by = NULL,
rows = NULL,
columns = NULL,
pages = NULL,
as.layers = FALSE,
nrows = NA,
ncols = NA,
byrow = TRUE,
orientation = NA,
free.coords = NA,
drop.units = TRUE,
drop.empty.facets = TRUE,
drop.NA.facets = FALSE,
sync = TRUE,
showNA = NA,
textNA = "Mssing",
scale.factor = 2,
type = NA,
along = NULL
)
tm_facets_grid(rows = NULL, columns = NULL, pages = NULL, ...)
tm_facets_wrap(by = "VARS__", nrows = NA, ncols = NA, byrow = TRUE, ...)
tm_facets_pagewise(by = "VARS__", nrows = 1, ncols = 1, byrow = TRUE, ...)
tm_facets_stack(by = "VARS__", orientation = NA, ...)
tm_facets_hstack(by = "VARS__", ...)
tm_facets_vstack(by = "VARS__", ...)
tm_facets_flip()
Arguments
- by
Group by variable (only for a facet wrap or facet stack)
- rows
Variable that specifies the rows (only for a facet grid)
- columns
Variable that specifies the columns (only for a facet grid)
- pages
Variable that specifies the pages (only for a facet grid)
- as.layers
show facets as layers?
- nrows
Number of rows
- ncols
Number of columns
- byrow
Should facets be wrapped by row?
- orientation
For facet stack: horizontal or vertical?
- free.coords
Logical. If the
by
argument is specified, should each map has its own coordinate ranges? By defaultTRUE
, unless facets are shown in as different layers (as.layers = TRUE
)- drop.units
Logical. If the
by
argument is specified, should non-selected spatial units be dropped? IfFALSE
, they are plotted where mapped aesthetics are regarded as missing values. Not applicable for raster shapes. By defaultTRUE
.- drop.empty.facets
Logical. If the
by
argument is specified, should empty facets be dropped? Empty facets occur when theby
-variable contains unused levels. WhenTRUE
and twoby
-variables are specified, empty rows and columns are dropped.- drop.NA.facets
Logical. If the
by
argument is specified, and all data values for specific facets are missing, should these facets be dropped?FALSE
by default.- sync
Logical. Should the navigation in view mode (zooming and panning) be synchronized? By default
TRUE
if the facets have the same bounding box. This is generally the case when rasters are plotted, or whenfree.coords
isFALSE
.- showNA
If the
by
argument is specified, should missing values of theby
-variable be shown in a facet? If twoby
-variables are specified, should missing values be shown in an additional row and column? IfNA
, missing values only are shown if they exist. Similar to theuseNA
argument of table(), whereTRUE
,FALSE
, andNA
correspond to"always"
,"no"
, and"ifany"
respectively.- textNA
Text used for facets of missing values.
- scale.factor
Number that determines how the elements (e.g. font sizes, symbol sizes, line widths) of the small multiples are scaled in relation to the scaling factor of the shapes. The elements are scaled to the
scale.factor
th root of the scaling factor of the shapes. So, forscale.factor=1
, they are scaled proportional to the scaling of the shapes. Since elements, especially text, are often too small to read, a higher value is recommended. By default,scale.factor=2
.- type
"grid"
,"wrap"
or"stack"
- along
deprecated Please use
tm_facets_page()
- ...
passed on to
tm_facets()