Plot legend for typology maps.
legendTypo(
pos = "topleft",
title.txt = "Title of the legend",
title.cex = 0.8,
values.cex = 0.6,
col,
categ,
cex = 1,
nodata = TRUE,
nodata.txt = "No data",
nodata.col = "white",
frame = FALSE,
symbol = "box"
)
position of the legend, one of "topleft", "top", "topright", "right", "bottomright", "bottom", "bottomleft", "bottomleftextra", "left" or a vector of two coordinates in map units (c(x, y)).
title of the legend.
size of the legend title.
size of the values in the legend.
a vector of colors.
vector of categories.
size of the legend. 2 means two times bigger.
if TRUE a "no data" box or line is plotted.
label for "no data" values.
color of "no data" values.
whether to add a frame to the legend (TRUE) or not (FALSE).
character; 'line' or 'box'
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()
# Define labels and colors
someLabels <- c("red color", "yellow color", "green color", "black color")
someColors <- c("red", "yellow", "green", "black")
# plot legend
legendTypo(pos = "bottomleft", title.txt = "Title of the legend", title.cex = 0.8,
values.cex = 0.6, col = someColors, categ = someLabels,
cex = 0.75,
nodata = TRUE, nodata.txt = "no data", frame = TRUE, symbol="box")
legendTypo(pos = "topright", title.txt = "",
title.cex = 1.5, cex = 1.25,
values.cex = 1, col = someColors, categ = someLabels,
nodata = FALSE, frame = FALSE, symbol="line")