Legend specification
tm_legend(
title,
show,
orientation,
design,
reverse,
na.show,
position,
width,
height,
stack,
z,
group.frame,
resize_as_group,
title.color,
title.size,
title.fontface,
title.fontfamily,
title.alpha,
title.padding,
title.align,
text.color,
text.size,
text.fontface,
text.fontfamily,
text.alpha,
format,
frame,
frame.lwd,
frame.r,
bg.color,
bg.alpha,
absolute_fontsize,
item.height,
item.width,
item.space,
item.na.height,
item.na.width,
item.na.space,
item.shape,
ticks,
ticks.disable.na,
ticks.col,
ticks.lwd,
margins,
item_text.margin,
...
)tm_legend_hide()
tm_legend_combine(variable)
tm_legend_bivariate(
xlab,
ylab,
xlab.color,
xlab.size,
xlab.fontface,
xlab.fontfamily,
xlab.alpha,
xlab.padding,
xlab.align,
ylab.color,
ylab.size,
ylab.fontface,
ylab.fontfamily,
ylab.alpha,
ylab.padding,
ylab.align,
...
)
A tm_legend component
Legend title
Show legend?
Orientation of the legend: "portrait"
or "landscape"
Legend design "standard"
. No other designs implemented yet.
Should the legend be reversed?
Show NA
values in legend?
An object created with tm_pos_in()
or tm_pos_out()
. Or, as a shortcut, a vector of two values, specifying the x and y coordinates. The first is "left"
, "center"
or "right"
(or upper case, meaning tighter to the map frame), the second "top"
, "center"
or "bottom"
. Numeric values are also supported, where 0, 0 means left bottom and 1, 1 right top. See also vignette about positioning.
Width of the legend. Units are 'text line heights'. In case a negative number is specified, the units are (approximate) pixels. The relation between these two is configured via the option absolute_fontsize
.
Height of the legend. Units are 'text line heights'. In case a negative number is specified, the units are (approximate) pixels. The relation between these two is configured via the option absolute_fontsize
.
stack with other map components, either "vertical"
or "horizontal"
.
z
group.frame
resize_as_group
The color of the title of the legend.
The size of the title of the legend.
The font face of the title of the legend. See graphics::par
, option 'font'.
The font family of the title of the legend. See graphics::par
, option 'family'.
The alpha transparency of the title of the legend.
The padding of the title of the legend. 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 align of the title of the legend.
The color of the text of the legend.
The size of the text of the legend.
The font face of the text of the legend. See graphics::par
, option 'font'.
The font family of the text of the legend. See graphics::par
, option 'family'.
The alpha transparency of the text of the legend.
Not used anymore: use the format argument of the tm_scale_*()
functions instead.
frame
frame line width
Radius of the rounded frame corners. 0 means no rounding.
The color of the bg of the legend.
The alpha transparency of the bg of the legend.
The absolute fontsize of the legend. So far, only used to calculate legend dimensions
The height of the item of the legend.
The width of the item of the legend.
The space of the item of the legend. In terms of number of text line heights.
The height of the na item of the legend.
The width of the na item of the legend.
The space of the na item of the legend. In terms of number of text line heights.
The shape of the item of the legend.
List of vectors of size 2 that determines the horizontal tick mark lines (for portrait legends). The values are the y-values of begin and endpoint of each tick mark.
Remove ticks for NA
values
The color of the ticks of the legend.
The line width of the ticks of the legend. See graphics::par
, option 'lwd'.
The margins of the legend. 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 margin of the space between item and text of the legend.
visual values, e.g. col
, fill
, lwd
, can be specified. If so, they overrule the default visual values, which are determined by the drawn map objects (e.g. polygons)
visual (or transformation) variable to combine the legend with: e.g. "fill"
or "size"
label for the x dimension (rows)
label for the y dimension (columns)
The color of the xlab of the legend.
The size of the xlab of the legend.
The font face of the xlab of the legend. See graphics::par
, option 'font'.
The font family of the xlab of the legend. See graphics::par
, option 'family'.
The alpha transparency of the xlab of the legend.
The padding of the xlab of the legend. 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 align of the xlab of the legend.
The color of the ylab of the legend.
The size of the ylab of the legend.
The font face of the ylab of the legend. See graphics::par
, option 'font'.
The font family of the ylab of the legend. See graphics::par
, option 'family'.
The alpha transparency of the ylab of the legend.
The padding of the ylab of the legend. 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 align of the ylab of the legend.
# Example using different settings from tm_legend()
tm_shape(World) +
tm_polygons(
fill = "HPI",
fill.legend = tm_legend(
title = "Home Price Index",
design = "standard",
title.color = "orange",
bg.color = "purple",
show = TRUE
),
id = "name",
# Format the labels using dollar sign
fill.scale = tm_scale_intervals(
label.format = function(x) format(x, big.mark = " ")),
)
Run the code above in your browser using DataLab