The viz_leg_typo_vertical function creates a vertical legend for
typology layers. The function adds a legend layer to the map.
Usage
viz_leg_typo_vertical(
map,
id = NULL,
pos = c(0, 0),
gap = 2,
types = c("A", "B", "C", "D"),
colors = c("#e41a1c", "#377eb8", "#4daf4a", "#984ea3"),
alphabetical = TRUE,
rect_width = 25,
rect_height = 17,
rect_spacing = 3,
rect_fill = "#5d6266",
rect_stroke = "#303030",
rect_strokeWidth = 0.1,
values_textAnchor = "start",
values_dx = 5,
values_dy = 0,
values_fill = "#363636",
values_fontSize = 10,
title = "Legend",
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. Legend position (default c(0, 0)).
- gap
numeric. Optional. Gap between elements (default 2).
- types
character vector. Optional. Types (default c("A", "B", "C", "D")).
- colors
character vector. Optional. Colors (default c("#e41a1c", "#377eb8", "#4daf4a", "#984ea3")).
- alphabetical
logical. Optional. Alphabetical order (default TRUE).
- rect_width
numeric. Optional. Width of the boxes (default 25).
- rect_height
numeric. Optional. Height of the boxes (default 17).
- rect_spacing
numeric. Optional. Spacing between boxes (default 3).
- rect_fill
character. Optional. Box fill color (default "#5d6266").
- rect_stroke
character. Optional. Stroke color (default "#303030").
- rect_strokeWidth
numeric. Optional. Stroke width (default 0.1).
- values_textAnchor
character. Optional. Text anchor (default "middle").
- values_dx
numeric. Optional. Horizontal shift (default 0).
- values_dy
numeric. Optional. Vertical shift (default 5).
- values_fill
character. Optional. Text color (default "#363636").
- values_fontSize
numeric. Optional. Font size (default 10).
- title
character. Optional. Legend title (default "Legend").
- title_fill
character. Optional. Title color (default "#363636").
- title_fontSize
numeric. Optional. Title font size (default 16).
- subtitle
character. Optional. Subtitle of the legend (default "").
- subtitle_fill
character. Optional. Subtitle color (default "#363636").
- subtitle_fontSize
numeric. Optional. Subtitle font size (default 12).
- note
character. Optional. Note displayed above the legend (default "").
- note_fill
character. Optional. Note color (default "#363636").
- note_fontSize
numeric. Optional. Note font size (default 10).
- frame
logical. Optional. Draw a frame around the legend (default FALSE).
- frame_margin
numeric. Optional. Frame margin (default 15).
- frame_fill
character. Optional. Frame fill color (default "white").
- frame_stroke
character. Optional. Frame stroke color (default "black").
- frame_fillOpacity
numeric. Optional. Frame fill opacity (default 0.5).
- ...
Additional SVG attributes passed to elements (e.g. rect_*, title_*, subtitle_*, note_*, frame_*, text_*).
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_typo_vertical(pos = c(20, 20)) |>
viz_render()