tm_scale_continuous | R Documentation |
Scales in tmap are configured by the family of functions with prefix tm_scale
.
Such function should be used for the input of the .scale
arguments in the layer
functions (e.g. fill.scale
in tm_polygons()
).
The function tm_scale_continuous()
is used for continuous data.
The functions tm_scale_continuous_<x>()
use transformation functions x.
tm_scale_continuous(
n = NULL,
limits = NULL,
outliers.trunc = NULL,
ticks = NULL,
trans = NULL,
midpoint = NULL,
values = NA,
values.repeat = FALSE,
values.range = NA,
values.scale = NA,
value.na = NA,
value.null = NA,
value.neutral = NA,
labels = NULL,
label.na = NA,
label.null = NA,
label.format = list(),
trans.args = list()
)
tm_scale_continuous_log(..., base = exp(1))
tm_scale_continuous_log2(...)
tm_scale_continuous_log10(...)
tm_scale_continuous_log1p(...)
tm_scale_continuous_sqrt(...)
tm_scale_continuous_pseudo_log(..., base = exp(1), sigma = 1)
n |
Preferred number of tick labels. Only used if |
limits |
Limits of the data values that are mapped to the continuous scale. When |
outliers.trunc |
Should outliers be truncated? An outlier is a data value that is below or above the respectively lower and upper limit. A logical vector of two values is expected. The first and second value determines whether values lower than the lower limit respectively higher than the upper limit are truncated to the lower respectively upper limit. If |
ticks |
Tick values. If not specified, it is determined automatically with |
trans |
Transformation function. One of |
midpoint |
The data value that is interpreted as the midpoint. By default it is set to 0 if negative and positive values are present. Useful when values are diverging colors. In that case, the two sides of the color palette are assigned to negative respectively positive values. If all values are positive or all values are negative, then the midpoint is set to |
values |
(generic scale argument) The visual values. For colors (e.g. |
values.repeat |
(generic scale argument) Should the values be repeated in case there are more categories? |
values.range |
(generic scale argument) Range of the values, especially useful for color palettes. Vector of two numbers (both between 0 and 1) where the first determines the minimum and the second the maximum. Full range, which means that all values are used, is encoded as |
values.scale |
(generic scale argument) Scaling of the values. Only useful for size-related visual variables, such as |
value.na |
(generic scale argument) Value used for missing values. See tmap option |
value.null |
(generic scale argument) Value used for NULL values. See tmap option |
value.neutral |
(generic scale argument) Value that can be considered neutral. This is used for legends of other visual variables of the same map layer. E.g. when both |
labels |
(generic scale argument) Labels |
label.na |
(generic scale argument) Label for missing values |
label.null |
(generic scale argument) Label for null (out-of-scope) values |
label.format |
(generic scale argument) Label formatting (similar to |
trans.args |
list of additional argument for the transformation (generic transformation arguments) |
... |
passed on to |
base |
base of logarithm |
sigma |
Scaling factor for the linear part of pseudo-log transformation. |
tm_scale()
tm_shape(World) +
tm_polygons(
fill = "HPI",
fill.scale = tm_scale_continuous(values = "scico.roma", midpoint = 30))
tm_shape(metro) +
tm_bubbles(
size = "pop1950",
size.scale = tm_scale_continuous(
values.scale = 1),
size.legend = tm_legend("Population in 1950", frame = FALSE))
tm_shape(metro) +
tm_bubbles(
size = "pop1950",
size.scale = tm_scale_continuous(
values.scale = 2,
limits = c(0, 12e6),
ticks = c(1e5, 3e5, 8e5, 4e6, 1e7),
labels = c("0 - 200,000", "200,000 - 500,000", "500,000 - 1,000,000",
"1,000,000 - 10,000,000", "10,000,000 or more"),
outliers.trunc = c(TRUE, TRUE)),
size.legend = tm_legend("Population in 1950", frame = FALSE))
# Note that for this type of legend, we recommend tm_scale_intervals()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.