The viz_proptypo function combines proportional symbols and
typology mapping on the same spatial data frame. It allows simultaneous encoding
of two variables using symbol size (quantitative) and categorical coloring.
Usage
viz_proptypo(
map,
data = NULL,
var1,
var2,
var = NULL,
symbol = "circle",
k = 50,
fixmax = NULL,
dodge = FALSE,
width = 30,
straight = 0,
colors = NULL,
order = NULL,
alphabetical = TRUE,
missing = "white",
legend = TRUE,
leg1_type = "nested",
leg2_type = "vertical",
leg1_pos = c(10, 10),
leg2_pos = NULL,
...
)Arguments
- map
A
geovizmap created withviz_create.- data
A spatial dataframe Use
datato enable iteration over features.- var1
character. Name of the numeric variable used for absolute values (driving symbol size).
- var2
character. Name of the numeric variable used for categorical mapping.
- var
character. Optional. If provided, the same variable is used for both size and color encoding.
- symbol
character. Optional. Symbol type (default "circle"). One of: "circle", "spike", "halfcircle".
- k
numeric. Optional. Size of the largest symbol (default 50).
- fixmax
numeric. Optional. Value corresponding to the symbol of size
k. Useful for ensuring comparability between maps.- dodge
logical. Optional. Avoid symbol overlap (default FALSE).
- width
numeric. Optional. Width of spike symbols (default 30).
- straight
numeric. Optional. Curvature of spike symbols (default 0). Value between 0 (curved) and 1 (straight).
- colors
character or vector. Optional. Color palette or vector of colors from the Dicopal library. See https://observablehq.com/@neocartocnrs/dicopal-library
- order
character vector. Optional. Explicit order of categorical values.
- alphabetical
logical. Optional. Whether to sort categories alphabetically (default TRUE).
- missing
character or logical. Optional. Color for missing values (default "white").
- legend
logical. Optional. Whether to display legends (default TRUE).
- leg1_type
character. Optional. Symbol legend type (default "nested").
- leg2_type
character. Optional. Typology legend type (default "vertical").
- leg1_pos
numeric vector. Optional. Position of symbol legend (default c(10, 10)).
- leg2_pos
numeric vector. Optional. Position of typology legend.
- ...
Additional parameters passed to rendering functions (e.g.
strokeWidth). Withleg1_andleg2_prefixes, you can configure the legends. For example:leg1_title,leg2_subtitle,leg1_note, etc.
Examples
library(sf)
world <- st_read(
system.file("gpkg/world.gpkg", package = "geoviz"),
quiet = TRUE
)
viz_create(
projection = "EqualEarth", background = "white",
zoomable = TRUE
) |>
viz_path(
datum = world, fill = "#f1f3f5"
) |>
viz_proptypo(
data = world, var1 = "pop", k = 25,
leg1_values_round = 0, var2 = "region",
leg1_title = "Population",
symbol = "square",
leg1_subtitle = "(million inh.)",
leg1_values_factor = 1 / 1000000,
leg2_title = "Continents",
colors = "Set3"
) |>
viz_render()