Plot legends for double proportional triangles maps.
legendPropTriangles(
pos = "topleft",
title.txt,
var.txt,
var2.txt,
title.cex = 0.8,
cex = 1,
values.cex = 0.6,
var,
var2,
r,
r2,
col = "red",
col2 = "blue",
frame = FALSE,
values.rnd = 0,
style = "c"
)
position of the legend, one of "topleft", "top", "topright", "right", "bottomright", "bottom", "bottomleft", "left" or a vector of two coordinates in map units (c(x, y)).
title of the legend.
name of var.
name of var2.
size of the legend title.
size of the legend. 2 means two times bigger.
size of the values in the legend.
a first vector of positive values.
a second vector of positive values.
a first vector of sizes.
a second vector of sizes.
color of symbols.
second color of symbols.
whether to add a frame to the legend (TRUE) or not (FALSE).
number of decimal places of the values in the legend.
either "c" or "e". The legend has two display styles, "c" stands for compact and "e" for extended.
library(sf)
mtq <- st_read(system.file("gpkg/mtq.gpkg", package="cartography"))
#> Reading layer `mtq' from data source
#> `/tmp/RtmpmpfIrO/temp_libpath18ee15f22a9e/cartography/gpkg/mtq.gpkg'
#> using driver `GPKG'
#> Simple feature collection with 34 features and 7 fields
#> Geometry type: MULTIPOLYGON
#> Dimension: XY
#> Bounding box: xmin: 690574 ymin: 1592536 xmax: 735940.2 ymax: 1645660
#> Projected CRS: WGS 84 / UTM zone 20N
plot(st_geometry(mtq))
box()
var <- runif(10, 0,100)
var2 <- runif(10, 0,100)
r <- sqrt(var)*1000
r2 <- sqrt(var2)*1000
legendPropTriangles(pos = "topright", var.txt = "population 1",
var2.txt = "population 2", title.txt="Population totale",
title.cex = 0.8, values.cex = 0.6, cex = 1,
var = var, var2 = var2, r = r, r2 = r2,
col="green", col2="yellow", frame=TRUE, values.rnd=2,
style="c")