View source: R/ttt_flowmapperlegend.R
| ttt_flowmapperlegend | R Documentation |
Build flowmaps legend
ttt_flowmapperlegend( x, pos = NULL, title = "Title 1", title2 = NULL, col = "#CCCCCC", txtcol = "black" )
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 |
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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.