mf_legend {mapsf}R Documentation

Plot a legend

Description

Plot all types of legend. The "type" argument defines the legend type:

Usage

mf_legend(
  type,
  pos,
  val,
  pal,
  col,
  inches,
  lwd,
  border,
  symbol,
  pt_pch,
  pt_cex,
  title,
  title_cex,
  val_cex,
  val_rnd,
  col_na,
  pt_cex_na,
  pt_pch_na,
  no_data,
  no_data_txt,
  frame,
  bg,
  fg,
  cex
)

Arguments

type

type of legend; one of "prop", "choro", "typo", "symb", "prop_line", "grad_line"

pos

position. It can be one of 'topleft', 'top','topright', 'right', 'bottomright', 'bottom','bottomleft', 'left', 'interactive' or a vector of two coordinates in map units (c(x, y))

val

a vector of values

pal

a set of colors or a palette name (from hcl.colors)

col

a color

inches

size of the biggest symbol (radius for circles, half width for squares) in inches.

lwd

line width(s)

border

border color

symbol

type of symbols, 'circle' or 'square'

pt_pch

pch of the symbols (0:25)

pt_cex

cex of the symbols

title

legend title

title_cex

size of the legend title

val_cex

size of the values in the legend

val_rnd

number of decimal places of the values in the legend

col_na

color for missing values

pt_cex_na

cex of the symbols for missing values

pt_pch_na

pch of the symbols for missing values

no_data

if TRUE a 'missing values' box is plotted

no_data_txt

label for missing values

frame

whether to add a frame to the legend (TRUE) or not (FALSE)

bg

background color

fg

foreground color

cex

size of the legend; 2 means two times bigger

Value

No return value, a legend is displayed.

Examples

mtq <- mf_get_mtq()
mf_map(mtq)
mf_legend(type = "prop", pos = "topright", val = c(1, 5, 10), inches = .3)
mf_legend(
  type = "choro", pos = "bottomright", val = c(10, 20, 30, 40, 50),
  pal = hcl.colors(4, "Reds 2")
)
mf_legend(
  type = "typo", pos = "topleft", val = c("A", "B", "C", "D"),
  pal = hcl.colors(4, "Dynamic")
)
mf_legend(
  type = "symb", pos = "bottomleft", val = c("A", "B", "C"),
  pt_pch = 21:23, pt_cex = c(1, 2, 2),
  pal = hcl.colors(3, "Dynamic")
)
mf_legend(
  type = "grad_line", pos = "top", val = c(1, 2, 3, 4, 10, 15),
  lwd = c(0.2, 2, 4, 5, 10)
)
mf_legend(type = "prop_line", pos = "bottom", lwd = 20, val = c(5, 50, 100))

[Package mapsf version 0.7.1 Index]