Specify the layout of the maps. tm_layout() is identical as tm_options() but only contain the tmap options that are directly related to the layout. tm_style() sets the style for the map. A style is a specified set of options (that can be changed afterwards with tm_layout()). These functions are used within a plot call (stacked with the + operator). Their counterparts tmap_options() and tmap_style() can be used to set the (layout) options globally.
tm_style(style, ...)tm_layout(
scale,
asp,
legend.only,
bg,
bg.color,
outer.bg,
outer.bg.color,
frame,
frame.color,
frame.alpha,
frame.lwd,
frame.r,
frame.double_line,
outer.margins,
inner.margins,
inner.margins.extra,
meta.margins,
meta.auto_margins,
between_margin,
text.fontfamily,
text.fontface,
r,
attr.color,
panel.margin,
panel.type,
panel.wrap.pos,
panel.xtab.pos,
color.sepia_intensity,
color.saturation,
color_vision_deficiency_sim,
panel.show,
panel.labels,
panel.label.size,
panel.label.color,
panel.label.fontface,
panel.label.fontfamily,
panel.label.alpha,
panel.label.bg,
panel.label.bg.color,
panel.label.bg.alpha,
panel.label.frame,
panel.label.frame.color,
panel.label.frame.alpha,
panel.label.frame.lwd,
panel.label.frame.r,
panel.label.height,
panel.label.rot,
earth_boundary,
earth_boundary.color,
earth_boundary.lwd,
earth_datum,
space,
space.color,
...
)
name of the style
List of tmap options to be set, or option names (characters) to be returned (see details)
Overall scale of the map
Aspect ratio of each map. When asp is set to NA (default) the aspect ratio will be adjusted to the used shapes. When set to 0 the aspect ratio is
adjusted to the size of the device divided by the number of columns and rows.
Should only legends be printed (so without map)?
Draw map background?
Background color of the map.
Draw map background (outside the frame)?
Background color of map outside the frame.
Draw map frame?
The color of the frame.
The alpha transparency of the frame.
The line width of the frame. See graphics::par, option 'lwd'.
The r (radius) of the frame.
The double line of the frame. TRUE or FALSE.
The margins of the outer space (outside the frame. A vector of 4 values: bottom, left, top, right. The unit is the device height (for bottom and top) or width (for left and right).
The margins of the inner space (inside the frame). A vector of 4 values: bottom, left, top, right. The unit is the device height (for bottom and top) or width (for left and right).
The extra arguments of the margins of the inner space (inside the frame). A list of arguments.
The margins of the 'meta' space (reserved for outside map components). A vector of 4 values: bottom, left, top, right. The unit is the device height (for bottom and top) or width (for left and right).
The auto_margins of the 'meta' space (reserved for outside map components).
Margin between the map.
The font family of the text. See graphics::par, option 'family'.
The font face of the text. See graphics::par, option 'font'.
The r (radius) (overall).
The color of the attr.
The margin of the panel.
The type of the panel.
The panel positions for wrapped facets created with tm_facets_grid(). One of "left", "right", "top" (default) or "bottom".
The panel positions for grid facets created with tm_facets_grid(). Vector of two, where the first determines the locations of row panels ("left" or "right") and the second the location of column panels ( "top" or `"bottom")
The sepia_intensity of the color.
The saturation of the color.
Color vision deficiency simulation. Either "protan", "deutan", or "tritan".
The visibility of the panel. TRUE or FALSE.
The labels of the panel.
The size of the label of the panel.
The color of the label of the panel.
The font face of the label of the panel. See graphics::par, option 'font'.
The font family of the label of the panel. See graphics::par, option 'family'.
The alpha transparency of the label of the panel.
The bg of the label of the panel.
The color of the bg of the label of the panel.
The alpha transparency of the bg of the label of the panel.
The frame of the label of the panel.
The color of the frame of the label of the panel.
The alpha transparency of the frame of the label of the panel.
The line width of the frame of the label of the panel. See graphics::par, option 'lwd'.
The r (radius) of the frame of the label of the panel.
The height of the label of the panel.
Rotation angles of the panel labels. Vector of four values that determine the panel label rotation when they are placed left, top, right, and bottom. The default angles are 90, 0, 270 and 0 respectively. Note that the second value is the most common, since labels are by default shown on top (see panel.wrap.pos). In cross-table facets created with tm_facets_grid(), the first two values are used by default (see panel.xtab.pos).
The earth boundary
The color of the earth_boundary.
The line width of the earth_boundary. See graphics::par, option 'lwd'.
Earth datum
Should the space be drawn? Only applicable is earth_boundary is enabled.
The color of the space.
When tm_style() is called, all layout options are reset according to that
style. To override specific layout options for a chosen style, call
tm_layout() after tm_style().
tm_shape(World) +
tm_polygons() +
tm_layout(
bg.color = "steelblue",
outer.bg.color = "gold",
frame.lwd = 3,
inner.margins = 0)
tm_shape(World) +
tm_polygons(fill = "HPI") +
tm_style("classic")
tm_shape(World) +
tm_polygons(fill = "HPI") +
tm_style("cobalt")
Run the code above in your browser using DataLab