tmap-element
that draws bubbles or small dots. Both colors and sizes of the bubbles can be mapped to data variables.tm_bubbles(size = 0.2, col = NA, alpha = NA, border.col = NA,
border.lwd = 1, border.alpha = NA, scale = 1, perceptual = FALSE,
size.lim = NA, sizes.legend = NULL, sizes.legend.labels = NULL, n = 5,
style = ifelse(is.null(breaks), "pretty", "fixed"), breaks = NULL,
palette = NULL, labels = NULL, auto.palette.mapping = TRUE,
contrast = 1, max.categories = 12, colorNA = NA, textNA = "Missing",
jitter = 0, 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)
tm_dots(col = NA, size = 0.02, title = NA, legend.is.portrait = TRUE,
legend.z = NA, ...)
shp
data variable that determines the bubble sizes. The reference value size=1
corresponds to the area of bubbles that have the same height as one line of text. If a data variable is provided, the bubble sizescol
is used (normally 1).NA
(default), no bubble borders are drawn.col
is used (normally 1).TRUE
) or mathematically (FALSE
, default value). The perceived area of larger bubbles is often underestimated. Flannery (1971) experimentally derived a methodsize
variable. Only bubbles are drawn whose value is greater than or equal to the first value. Bubbles whose values exceed the second value are drawn at the size of the second value. Only applicable when sizes.legend
.col
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 bubbles. Only when col
is set to a variable. The default palette is taken from tm_layout
's argument aes.palette
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 legendjitter
times the height oymod
, it determilabels
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
).title.col
for tm_dots
legend.col.is.portrait
for tm_dots
legend.col.z shortcut
for tm_dots
tm_bubbles
by
argument in tm_facets
, or by defining multiple variables in the aesthetic arguments. The aesthetic arguments of tm_bubbles
are size
and col
. In the latter case, the arguments, except for the ones starting with legend.
, can be specified for small multiples as follows. If the argument normally only takes a single value, such as n
, then a vector of those values can be specified, one for each small multiple. If the argument normally can take a vector, such as palette
, then a list of those vectors (or values) can be specified, one for each small multiple.vignette("tmap-nutshell")
}data(World, metro)
metro$growth <- (metro$pop2020 - metro$pop2010) / (metro$pop2010 * 10) * 100
tm_shape(World) +
tm_fill("grey70") +
tm_shape(metro) +
tm_bubbles("pop2010", col = "growth",
border.col = "black", border.alpha = .5,
style="fixed", breaks=c(-Inf, seq(0, 6, by=2), Inf),
palette="-RdYlBu", contrast=1,
title.size="Metro population",
title.col="Growth rate (%)") +
tm_format_World()
x <- sample_dots(World, vars="gdp_md_est", convert2density = TRUE, w = 100000)
tm_shape(x) +
tm_dots() +
tm_layout("World GDP (one dot is 100 billon dollars)", title.position = c("right", "bottom"))
Run the code above in your browser using DataLab