View source: R/tm_layers_text.R
opt_tm_text | R Documentation |
Map layer that draws symbols Supported visual variables are: text
(the text itself) col
(color), size
(font size), and fontface
(font face).
opt_tm_text(
points.only = "ifany",
shadow = FALSE,
shadow.offset.x = 0.1,
shadow.offset.y = 0.1,
just = "center",
along.lines = FALSE,
bg.padding = 0.4,
clustering = FALSE,
point.label = FALSE,
point.label.gap = 0,
point.label.method = "SANN",
remove.overlap = FALSE
)
opt_tm_labels(
points.only = "ifany",
shadow = FALSE,
shadow.offset.x = 0.1,
shadow.offset.y = 0.1,
just = "center",
along.lines = TRUE,
bg.padding = 0.4,
clustering = TRUE,
point.label = TRUE,
point.label.gap = 0.4,
point.label.method = "SANN",
remove.overlap = FALSE
)
opt_tm_markers(
markers.on.top.of.text = FALSE,
points.only = "ifany",
shadow = FALSE,
just = "center",
along.lines = TRUE,
bg.padding = 0.4,
clustering = TRUE,
point.label = TRUE,
point.label.gap = 0.4,
point.label.method = "SANN",
remove.overlap = FALSE,
dots.just = NA,
dots.icon.scale = 3,
dots.grob.dim = c(width = 48, height = 48, render.width = 256, render.height = 256)
)
tm_text(
text = tm_const(),
text.scale = tm_scale(),
text.legend = tm_legend(),
text.chart = tm_chart_none(),
text.free = NA,
size = tm_const(),
size.scale = tm_scale(),
size.legend = tm_legend(),
size.chart = tm_chart_none(),
size.free = NA,
col = tm_const(),
col.scale = tm_scale(),
col.legend = tm_legend(),
col.chart = tm_chart_none(),
col.free = NA,
col_alpha = tm_const(),
col_alpha.scale = tm_scale(),
col_alpha.legend = tm_legend(),
col_alpha.chart = tm_chart_none(),
col_alpha.free = NA,
fontface = tm_const(),
fontface.scale = tm_scale(),
fontface.legend = tm_legend(),
fontface.chart = tm_chart_none(),
fontface.free = NA,
fontfamily = "",
bgcol = tm_const(),
bgcol.scale = tm_scale(),
bgcol.legend = tm_legend(),
bgcol.chart = tm_chart_none(),
bgcol.free = NA,
bgcol_alpha = tm_const(),
bgcol_alpha.scale = tm_scale(),
bgcol_alpha.legend = tm_legend(),
bgcol_alpha.chart = tm_chart_none(),
bgcol_alpha.free = NA,
xmod = 0,
xmod.scale = tm_scale(),
xmod.legend = tm_legend_hide(),
xmod.chart = tm_chart_none(),
xmod.free = NA,
ymod = 0,
ymod.scale = tm_scale(),
ymod.legend = tm_legend_hide(),
ymod.chart = tm_chart_none(),
ymod.free = NA,
angle = 0,
angle.scale = tm_scale(),
angle.legend = tm_legend_hide(),
angle.chart = tm_chart_none(),
angle.free = NA,
plot.order = tm_plot_order("size", reverse = FALSE),
zindex = NA,
group = NA,
group.control = "check",
options = opt_tm_text(),
...
)
tm_labels(
text = tm_const(),
text.scale = tm_scale(),
text.legend = tm_legend(),
text.chart = tm_chart_none(),
text.free = NA,
size = tm_const(),
size.scale = tm_scale(),
size.legend = tm_legend(),
size.chart = tm_chart_none(),
size.free = NA,
col = tm_const(),
col.scale = tm_scale(),
col.legend = tm_legend(),
col.chart = tm_chart_none(),
col.free = NA,
col_alpha = tm_const(),
col_alpha.scale = tm_scale(),
col_alpha.legend = tm_legend(),
col_alpha.chart = tm_chart_none(),
col_alpha.free = NA,
fontface = tm_const(),
fontface.scale = tm_scale(),
fontface.legend = tm_legend(),
fontface.chart = tm_chart_none(),
fontface.free = NA,
fontfamily = "",
bgcol = tm_const(),
bgcol.scale = tm_scale(),
bgcol.legend = tm_legend(),
bgcol.chart = tm_chart_none(),
bgcol.free = NA,
bgcol_alpha = tm_const(),
bgcol_alpha.scale = tm_scale(),
bgcol_alpha.legend = tm_legend(),
bgcol_alpha.chart = tm_chart_none(),
bgcol_alpha.free = NA,
xmod = 0,
xmod.scale = tm_scale(),
xmod.legend = tm_legend_hide(),
xmod.chart = tm_chart_none(),
xmod.free = NA,
ymod = 0,
ymod.scale = tm_scale(),
ymod.legend = tm_legend_hide(),
ymod.chart = tm_chart_none(),
ymod.free = NA,
angle = 0,
angle.scale = tm_scale(),
angle.legend = tm_legend_hide(),
angle.chart = tm_chart_none(),
angle.free = NA,
plot.order = tm_plot_order("AREA", reverse = FALSE, na.order = "bottom"),
zindex = NA,
group = NA,
group.control = "check",
options = opt_tm_labels(),
...
)
tm_markers(
text = tm_const(),
text.scale = tm_scale(),
text.legend = tm_legend(),
text.chart = tm_chart_none(),
text.free = NA,
size = tm_const(),
size.scale = tm_scale(),
size.legend = tm_legend(),
size.chart = tm_chart_none(),
size.free = NA,
col = tm_const(),
col.scale = tm_scale(),
col.legend = tm_legend(),
col.chart = tm_chart_none(),
col.free = NA,
col_alpha = tm_const(),
col_alpha.scale = tm_scale(),
col_alpha.legend = tm_legend(),
col_alpha.chart = tm_chart_none(),
col_alpha.free = NA,
fontface = tm_const(),
fontface.scale = tm_scale(),
fontface.legend = tm_legend(),
fontface.chart = tm_chart_none(),
fontface.free = NA,
fontfamily = "",
bgcol = tm_const(),
bgcol.scale = tm_scale(),
bgcol.legend = tm_legend(),
bgcol.chart = tm_chart_none(),
bgcol.free = NA,
bgcol_alpha = tm_const(),
bgcol_alpha.scale = tm_scale(),
bgcol_alpha.legend = tm_legend(),
bgcol_alpha.chart = tm_chart_none(),
bgcol_alpha.free = NA,
xmod = 0,
xmod.scale = tm_scale(),
xmod.legend = tm_legend_hide(),
xmod.chart = tm_chart_none(),
xmod.free = NA,
ymod = 0,
ymod.scale = tm_scale(),
ymod.legend = tm_legend_hide(),
ymod.chart = tm_chart_none(),
ymod.free = NA,
angle = 0,
angle.scale = tm_scale(),
angle.legend = tm_legend_hide(),
angle.chart = tm_chart_none(),
angle.free = NA,
plot.order = tm_plot_order("AREA", reverse = FALSE, na.order = "bottom"),
zindex = NA,
group = NA,
group.control = "check",
options = opt_tm_markers(),
...
)
points.only |
should only point geometries of the shape object (defined in |
shadow |
Shadow behind the text. Logical or color. |
shadow.offset.x , shadow.offset.y |
Shadow offset in line heights |
just |
justification of the text relative to the point coordinates. Either one of the following values: |
along.lines |
logical that determines whether labels are rotated along the spatial lines. Only applicable if a spatial lines shape is used. |
bg.padding |
The padding of the background in terms of line heights. |
clustering |
value that determines whether the text labels are clustered in |
point.label |
logical that determines whether the labels are placed automatically. |
point.label.gap |
numeric that determines the gap between the point and label |
point.label.method |
the optimization method, either |
remove.overlap |
logical that determines whether the overlapping labels are removed |
markers.on.top.of.text |
should markers be plot on top of the text (by default |
dots.just |
justification of the text relative to the point coordinates. Either one of the following values: |
dots.icon.scale |
scaling number that determines how large the icons (or grobs) are in plot mode in comparison to proportional symbols (such as bubbles). In view mode, the size is determined by the icon specification (see |
dots.grob.dim |
vector of four values that determine how grob objects (see details) are shown in view mode. The first and second value are the width and height of the displayed icon. The third and fourth value are the width and height of the rendered png image that is used for the icon. Generally, the third and fourth value should be large enough to render a ggplot2 graphic successfully. Only needed for the view mode. |
text , text.scale , text.legend , text.chart , text.free |
Visual variable that determines the text. See details. |
size , size.scale , size.legend , size.chart , size.free |
Visual variable that determines the font size. See details. |
col , col.scale , col.legend , col.chart , col.free |
Visual variable that determines the col color. See details. |
col_alpha , col_alpha.scale , col_alpha.legend , col_alpha.chart , col_alpha.free |
Visual variable that determines the border color alpha transparency. See Details. |
fontface , fontface.scale , fontface.legend , fontface.chart , fontface.free |
Visual variable that determines the font face. See Details. |
fontfamily |
The font family. See gpar() for details. |
bgcol , bgcol.scale , bgcol.legend , bgcol.chart , bgcol.free |
Visual variable that determines the background color. See Details. |
bgcol_alpha , bgcol_alpha.scale , bgcol_alpha.legend , bgcol_alpha.chart , bgcol_alpha.free |
Visual variable that determines the background color transparency. See Details. |
xmod , xmod.scale , xmod.legend , xmod.chart , xmod.free |
Transformation variable that determines the x offset. See details. |
ymod , ymod.scale , ymod.legend , ymod.chart , ymod.free |
Transformation variable that determines the y offset. See details. the text. See details. |
angle , angle.scale , angle.legend , angle.chart , angle.free |
Rotation angle |
plot.order |
Specification in which order the spatial features are drawn.
See |
zindex |
Map layers are drawn on top of each other. The |
group |
Name of the group to which this layer belongs. This is only
relevant in view mode, where layer groups can be switched (see |
group.control |
In view mode, the group control determines how layer
groups can be switched on and off. Options: |
options |
options passed on to the corresponding |
... |
to catch deprecated arguments from version < 4.0 |
The visual variable arguments (e.g. col
) can be specified with either a
data variable name (of the object specified in tm_shape()
), or with a visual
value (for col
, a color is expected). Multiple values can be specified:
in that case facets are created. These facets can be combined with other
faceting data variables, specified with tm_facets()
.
The .scale
arguments determine the used scale to map the data values to
visual variable values. These can be specified with one of the available
tm_scale_()
functions. The default scale that is used is specified by the
tmap option scales.var
.
The .legend
arguments determine the used legend, specified with tm_legend()
.
The default legend and its settings are determined by the tmap options legend.
.
The .free
arguments determine whether scales are applied freely across facets,
or shared. A logical value is required. They can also be specified with a
vector of three logical values; these determine whether scales are applied
freely per facet dimension. This is only useful when facets are applied
(see tm_facets()
). There are maximally three facet dimensions: rows, columns,
and pages. This only applies for a facet grid (tm_facets_grid()
).
For instance, col.free = c(TRUE, FALSE, FALSE)
means that for the visual
variable col
, each row of facets will has its own scale, and therefore its
own legend. For facet wraps and stacks (tm_facets_wrap()
and tm_facets_stack()
)
there is only one facet dimension, so the .free
argument requires only one logical value.
tm_shape(World, bbox = World) +
tm_text("name", size="pop_est", col="continent",
col.scale = tm_scale_categorical(values = "seaborn.dark"),
col.legend = tm_legend_hide(),
size.scale = tm_scale_continuous(values.scale = 4),
size.legend = tm_legend_hide())
metro$upside_down = ifelse(sf::st_coordinates(metro)[,2] < 0, 180, 0)
tm_shape(metro) +
tm_text(text = "name", size = "pop2020",
angle = "upside_down", size.legend = tm_legend_hide(),
col = "upside_down",
col.scale = tm_scale_categorical(values = c("#9900BB", "#228822")),
col.legend = tm_legend_hide()) +
tm_title_out("Which Hemisphere?", position = tm_pos_out("center", "top", pos.v = "bottom"))
metroAfrica = sf::st_intersection(metro, World[World$continent == "Africa", ])
Africa = World[World$continent == "Africa", ]
tm_shape(land) +
tm_raster("cover_cls",
col.scale = tm_scale(
values = cols4all::c4a("brewer.pastel1")[c(3,7,7,2,6,1,2,2)]
),
col.legend = tm_legend_hide()) +
tm_shape(rivers) +
tm_lines(lwd = "strokelwd", lwd.scale = tm_scale_asis(values.scale = .3),
col = cols4all::c4a("brewer.pastel1")[2]) +
tm_shape(Africa, is.main = TRUE) +
tm_borders() +
tm_shape(metroAfrica) +
tm_symbols(fill = "red", shape = "pop2020", size = "pop2020",
size.scale = tm_scale_intervals(
breaks = c(1, 2, 5, 10, 15, 20, 25) * 1e6,
values.range = c(0.2,2)
),
size.legend = tm_legend("Population in 2020"),
shape.scale = tm_scale_intervals(
breaks = c(1, 2, 5, 10, 15, 20, 25) * 1e6,
values = c(21, 23, 22, 21, 23, 22)
),
shape.legend = tm_legend_combine("size")) +
tm_labels("name")
tm_shape(metroAfrica) +
tm_markers(text = "name",
dots_fill = "red",
dots_size = 0.3)
tm_shape(metroAfrica) +
tm_markers(text = "name",
dots_shape = marker_icon(),
dots_col = NA,
dots_fill = "red",
dots_size = 2,
ymod = -0.25,
options = opt_tm_markers(point.label = FALSE, remove.overlap = TRUE))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.