The viz_dotdensity function creates a dot density map by
distributing points proportionally to a numeric variable. Each dot represents
a fixed quantity of the underlying data.
Usage
viz_dotdensity(
map,
data = NULL,
var,
stroke = "none",
r = 1,
dotval = NULL,
fill = "black",
legend = TRUE,
leg_pos = NULL,
leg_text = NULL,
...
)Arguments
- map
A
geovizmap created withviz_create.- data
A spatial dataframe Use
datato enable iteration over features.- var
character. Name of the numeric variable used to generate dot density values.
- stroke
character. Optional. Stroke color for dots (default "none").
- r
numeric. Optional. Radius of each dot (default 1).
- dotval
numeric. Optional. Value represented by a single dot. If not provided, it is computed automatically.
- fill
character. Optional. Fill color of dots (default "black").
- legend
logical. Optional. Whether to display legend (default TRUE).
- leg_pos
numeric vector. Optional. Legend position (default c(10, svg.height - 10)).
- leg_text
character. Optional. Legend text (default dot value).
- ...
Additional parameters passed to rendering or SVG container options.
Examples
library(sf)
world <- st_read(
system.file("gpkg/world.gpkg", package = "geoviz"),
quiet = TRUE
)
cities <- st_read(
system.file("gpkg/cities.gpkg", package = "geoviz"),
quiet = TRUE
)
viz_create(projection = "EqualEarth") |>
viz_path(datum = world, fill = "#f1f3f5") |>
viz_dotdensity(data = cities, var = "population") |>
viz_render()