Skip to contents

The viz_leg_mushrooms function adds a legend for proportional half-circles. It displays two sets of nested half-circles (top and bottom), each scaled according to input values. The function adds a legend layer to the SVG container and returns the layer identifier.

Usage

viz_leg_mushrooms(
  map,
  id = NULL,
  pos = c(0, 0),
  gap = 2,
  line_stroke = "#363636",
  line_strokeDasharray = "1",
  line_strokeWidth = 0.7,
  line_length = 10,
  top_data = NULL,
  top_k = 50,
  top_fixmax = NULL,
  top_nb = 4,
  top_circle_fill = "none",
  top_circle_stroke = "black",
  top_circle_cornerRadius = 5,
  top_values_textAnchor = "start",
  top_values_dx = 5,
  top_values_dy = 0,
  top_values_factor = 1,
  top_values_decimal = ".",
  top_values_thousands = " ",
  top_title = "top_title",
  bottom_data = NULL,
  bottom_k = 50,
  bottom_fixmax = NULL,
  bottom_nb = 4,
  bottom_circle_fill = "none",
  bottom_circle_stroke = "black",
  bottom_circle_cornerRadius = 5,
  bottom_values_textAnchor = "start",
  bottom_values_dx = 5,
  bottom_values_dy = 0,
  bottom_values_factor = 1,
  bottom_values_decimal = ".",
  bottom_values_thousands = " ",
  bottom_title = "bottom_title",
  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 geoviz object created with viz_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).

line_stroke

character. Optional. Line stroke color (default "#363636").

line_strokeDasharray

character. Optional. Dash pattern (default "1").

line_strokeWidth

numeric. Optional. Line width (default 0.7).

line_length

numeric. Optional. Line length (default 10).

top_data

numeric vector. Optional. Input values for top half-circles.

top_k

numeric. Optional. Radius of largest top half-circle (default 50).

top_fixmax

numeric. Optional. Value mapped to radius k.

top_nb

numeric. Optional. Number of top half-circles (default 4).

top_circle_fill

character. Optional. Fill color (default "none").

top_circle_stroke

character. Optional. Stroke color (default "black").

top_circle_cornerRadius

numeric. Optional. Corner radius (default 5).

top_values_textAnchor

character. Optional. Text anchor (default "start").

top_values_dx

numeric. Optional. X shift (default 5).

top_values_dy

numeric. Optional. Y shift (default 0).

top_values_factor

numeric. Optional. Scaling factor (default 1).

top_values_decimal

character. Optional. Decimal separator (default ".").

top_values_thousands

character. Optional. Thousands separator (default " ").

top_title

character. Optional. Title of top legend part (default "top_title").

bottom_data

numeric vector. Optional. Input values for bottom half-circles.

bottom_k

numeric. Optional. Radius of largest bottom half-circle (default 50).

bottom_fixmax

numeric. Optional. Value mapped to radius k.

bottom_nb

numeric. Optional. Number of bottom half-circles (default 4).

bottom_circle_fill

character. Optional. Fill color (default "none").

bottom_circle_stroke

character. Optional. Stroke color (default "black").

bottom_circle_cornerRadius

numeric. Optional. Corner radius (default 5).

bottom_values_textAnchor

character. Optional. Text anchor (default "start").

bottom_values_dx

numeric. Optional. X shift (default 5).

bottom_values_dy

numeric. Optional. Y shift (default 0).

bottom_values_factor

numeric. Optional. Scaling factor (default 1).

bottom_values_decimal

character. Optional. Decimal separator (default ".").

bottom_values_thousands

character. Optional. Thousands separator (default " ").

bottom_title

character. Optional. Title of bottom legend part (default "bottom_title").

title

character. Optional. Legend title (default "Legend").

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_mushrooms(pos = c(20, 20)) |>
viz_render()