tmap-element that adds text labels.tm_text(text, size = 1, col = NA, root = 3, size.lim = NA,
sizes.legend = NULL, sizes.legend.labels = NULL,
sizes.legend.text = "Abc", n = 5, style = ifelse(is.null(breaks),
"pretty", "fixed"), breaks = NULL, palette = NULL, labels = NULL,
labels.text = NA, auto.palette.mapping = TRUE, contrast = 1,
max.categories = 12, colorNA = NA, textNA = "Missing", fontface = NA,
fontfamily = NA, alpha = NA, case = NA, shadow = FALSE,
bg.color = NA, bg.alpha = NA, size.lowerbound = 0.4,
print.tiny = FALSE, scale = 1, auto.placement = FALSE,
remove.overlap = FALSE, along.lines = FALSE, overwrite.lines = FALSE,
xmod = 0, ymod = 0, title.size = NA, title.col = NA,
legend.size.show = TRUE, legend.col.show = TRUE, legend.format = list(),
legend.size.is.portrait = FALSE, legend.col.is.portrait = TRUE,
legend.hist = FALSE, legend.hist.title = NA, legend.size.z = NA,
legend.col.z = NA, legend.hist.z = NA, id = NA)"AREA", where the text size is proportional to the area size of the polsize is a variable name or "AREA". If root=2, the square root is taken, if root=3, the cube root etc.size variable. Only text labels are drawn whose value is greater than or equal to the first value. Text labels whose values exceed the second value are drawn at the size of the second value. Only applicable wsizes.legend.NA, examples from the data variable whose sizes are close to the sizes.legend are taken and "NA" for classes where no match is foundcol is a numeric variable name.col is a numeric variable. Discrete options are "cat", "fixed", "sd", "equal", "pretty", "quantile", "kmeans", <style=="fixed", breaks should be specifiedRColorBrewer::display.brewer.all) for the text. Only when col is set to a variable. The default palette is taken from tm_layout's argument aes.palettecol is a data variable namelabels. When NA (default), examples from the data variable are taken and "NA" for classes where they don't exist.auto.palette.mapping=TRUE). Both numbers should be between 0 and 1. The first number determines where the palette begins, and tcol is the name of a categorical variable, this value determines how many categories (levels) it can have maximally. If the number of levels is higher than max.categories, then levels are combined.NA to omit text for missing values in the legendtm_layout.tm_layout.fontcolor is used (normally 1).NA to leave the text as is.fontcolor.bg.color=NA, so no background is drawn.size. Only applicable when size is not a constant. If print.tiny is TRUE, then all text labels which relative text is smaller than size.lowerbound are depicted at relative sizsize.lowerboundsize is variable or "AREA".TRUE, the labels are placed next to the coordinate points with as little overlap as possible using the simulated annealing algorithm. Therefore, it is recommlabels is undefined. Parameters are:
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]TRUE) or landscape (FALSE)TRUE) or landscape (FALSE)legend.size.z)legend.size.z)itmap).vignette("tmap-nutshell")}data(World, Europe, metro)
tm_shape(World) +
tm_text("name", size="AREA")
tm_shape(Europe) +
tm_polygons() +
tm_text("iso_a3", size="AREA", col = "grey20", root=4, shadow = TRUE, scale=2,
size.lowerbound = .1) +
tm_shape(Europe) +
tm_text("name", size="AREA", root=4, scale=1,
ymod=-1 * approx_areas(Europe, unit = "norm")^(1/4))
tm_shape(Europe) +
tm_polygons() +
tm_shape(metro) +
tm_bubbles("pop2010", size.lim = c(0, 15e6), legend.size.is.portrait = TRUE,
title.size = "European metropolitan areas") +
tm_shape(metro[metro$pop2010>=2e6, ]) +
tm_text("name", auto.placement = TRUE)
tm_shape(World) +
tm_text("name", size="pop_est", col="continent", palette="Dark2",
title.size = "Population", title.col="Continent")Run the code above in your browser using DataLab