The viz_leg_spikes function adds a legend for spike marks.
It draws a series of spikes with heights proportional to values.
The function adds a legend layer to the SVG container.
Usage
viz_leg_spikes(
map,
id = NULL,
pos = c(0, 0),
gap = 2,
data = c(1, 1000),
k = 50,
fixmax = NULL,
nb = 4,
spike_width = 30,
spike_straight = 0,
spike_spacing = 3,
spike_fill = "none",
spike_stroke = "black",
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. ID of the layer.
- pos
numeric vector of length 2. Optional. Position (default c(0, 0)).
- gap
numeric. Optional. Gap between elements (default 2).
- data
numeric vector. Optional. Input values (default c(1, 200, 500, 1000)).
- k
numeric. Optional. Height of the highest spike (default 50).
- fixmax
numeric. Optional. Value mapped to height k.
- nb
numeric. Optional. Number of spikes (default 4).
- spike_width
numeric. Optional. Width of spikes (default 30).
- spike_straight
numeric. Optional. Shape of spikes (0 = curved, 1 = straight, default 0).
- spike_spacing
numeric. Optional. Spacing between spikes (default 3).
- spike_fill
character. Optional. Fill color (default "none").
- spike_stroke
character. Optional. Stroke color (default "black").
- values_textAnchor
character. Optional. Text anchor (default "start").
- values_dx
numeric. Optional. Shift in x (default 0).
- values_dy
numeric. Optional. Shift in y (default 5).
- values_fill
character. Optional. Label color (default "#363636").
- values_fontSize
numeric. Optional. Font size (default 10).
- values_factor
numeric. Optional. Multiplicative 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_spikes(pos = c(20, 20)) |>
viz_render()