The viz_leg_circles function adds a legend for proportional circles.
It draws circles scaled by values, with optional reference lines and labels.
The function adds a legend layer to the SVG container.
Usage
viz_leg_circles(
map,
id = NULL,
pos = c(0, 0),
gap = 2,
data = c(1, 1000),
k = 50,
fixmax = NULL,
nb = 4,
circle_fill = "none",
circle_stroke = "#363636",
circle_spacing = 5,
line_stroke = "#363636",
line_strokeDasharray = "1",
line_strokeWidth = 0.7,
line_length = 10,
values_textAnchor = "start",
values_dx = 5,
values_dy = 0,
values_fill = "#363636",
values_fontSize = 10,
values_factor = 1,
values_decimal = ".",
values_thousands = " ",
title = "",
title_fill = "#363636",
title_fontSize = 16,
subtitle = "",
subtitle_fill = "#363636",
subtitle_fontSize = 12,
note = "",
note_fill = "#363636",
note_fontSize = 10,
frame = FALSE,
frame_margin = 15,
frame_fill = "white",
frame_stroke = "black",
frame_fillOpacity = 0.5,
...
)Arguments
- map
A
geovizobject created withviz_create.- id
character. Optional. Unique layer id.
- pos
numeric vector of length 2. Optional. Legend position (default c(0, 0)).
- gap
numeric. Optional. Gap between elements (default 2).
- data
numeric vector. Required. Input values.
- k
numeric. Optional. Radius of largest circle (default 50).
- fixmax
numeric. Optional. Value mapped to radius k.
- nb
numeric. Optional. Number of circles (default 4).
- circle_fill
character. Optional. Circle fill (default "none").
- circle_stroke
character. Optional. Circle stroke (default "#363636").
- circle_spacing
numeric. Optional. Spacing between circles (default 5).
- line_stroke
character. Optional. Line stroke color (default "#363636").
- line_strokeDasharray
character. Optional. Line dash style (default "1").
- line_strokeWidth
numeric. Optional. Line width (default 0.7).
- line_length
numeric. Optional. Line length (default 10).
- values_textAnchor
character. Optional. Text anchor (default "start").
- values_dx
numeric. Optional. X shift (default 5).
- values_dy
numeric. Optional. Y shift (default 0).
- values_fill
character. Optional. Label color (default "#363636").
- values_fontSize
numeric. Optional. Font size (default 10).
- values_factor
numeric. Optional. Scaling factor (default 1).
- values_decimal
character. Optional. Decimal separator (default ".").
- values_thousands
character. Optional. Thousands separator (default " ").
- title
character. Optional. Title (default "").
- title_fill
character. Optional. Title color (default "#363636").
- title_fontSize
numeric. Optional. Title size (default 16).
- subtitle
character. Optional. Subtitle (default "").
- subtitle_fill
character. Optional. Subtitle color (default "#363636").
- subtitle_fontSize
numeric. Optional. Subtitle size (default 12).
- note
character. Optional. Note (default "").
- note_fill
character. Optional. Note color (default "#363636").
- note_fontSize
numeric. Optional. Note size (default 10).
- frame
logical. Optional. Draw frame (default FALSE).
- frame_margin
numeric. Optional. Frame margin (default 15).
- frame_fill
character. Optional. Frame fill (default "white").
- frame_stroke
character. Optional. Frame stroke (default "black").
- frame_fillOpacity
numeric. Optional. Frame opacity (default 0.5).
- ...
Additional SVG attributes.
Examples
library(sf)
world <- st_read(
system.file("gpkg/world.gpkg", package = "geoviz"),
quiet = TRUE
)
viz_create(projection = "EqualEarth", background = "white") |>
viz_path(datum = world, fill = "#f1f3f5") |>
viz_leg_circles(pos = c(20, 20)) |>
viz_render()