ttt_flowmapperlegend: Flowmapper Legend

View source: R/ttt_flowmapperlegend.R

ttt_flowmapperlegendR Documentation

Flowmapper Legend

Description

Build flowmaps legend

Usage

ttt_flowmapperlegend(
  x,
  pos = NULL,
  title = "Title 1",
  title2 = NULL,
  col = "#CCCCCC",
  txtcol = "black"
)

Arguments

x

flow generetd with the function plotflows(). list.

title

title of the legend (flows), default is "Title".

title2

title of the legend (circles), default is NULL.

col

color of the legend, default is #CCCCC

txtcol

color of the text, default is black

Examples

library(sf)
crs <- "+proj=robin +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs"
subregions <- st_read(system.file("subregions.gpkg", package="flowmapper")) %>% st_transform(crs)
migr <- read.csv(system.file("migrantstocks2019.csv", package="flowmapper"))
threshold <- 1500
migr <- migr[migr$fij >= threshold,]
intra <- migr[migr$i == migr$j,c("i","fij")]
colnames(intra) <- c("id","nb")

plot(st_geometry(subregions), col = "#CCCCCC", border = "white", lwd = 0.5)
flows <- ttt_flowmapper(
       x = subregions,
       xid = "id",
       df = migr,
        dfid = c("i","j"),
        dfvar = "fij",
       size = "area",
        type = "arrows",
        decreasing = FALSE,
        add = TRUE,
       lwd = 1,
       col = "#00FF0090",
        border = "#4a0c25",
       df2 = intra,
      df2id = "id",
     df2var = "nb"
)

ttt_flowmapperlegend(x = flows, title = "inter", title2 = "intra")

tributetotobler/ttt documentation built on Sept. 15, 2022, 5:41 p.m.