library(sf)
mtq <- st_read(system.file("gpkg/mtq.gpkg", package = "cartography"),
quiet = TRUE)
# number of employed persons
mtq$EMP <- mtq$ACT - mtq$CHOM
plot(st_geometry(mtq),
col = "#f2efe9",
border = "#b38e43",
lwd = 0.5)
waffleLayer(
x = mtq,
var = c("EMP", "CHOM"),
cellvalue = 100,
cellsize = 400,
cellrnd = "ceiling",
celltxt = "1 cell represents 100 persons",
labels = c("Employed", "Unemployed"),
ncols = 6,
col = c("tomato1", "lightblue"),
border = "#f2efe9",
legend.pos = "topright",
legend.title.cex = 1,
legend.title.txt = "Active Population",
legend.values.cex = 0.8,
add = TRUE
)
layoutLayer(
title = "Structure of the Active Population",
col = "tomato4",
tabtitle = TRUE,
scale = FALSE,
sources = paste0("cartography ", packageVersion("cartography")),
author = "Sources: Insee and IGN, 2018",
)
Run the code above in your browser using DataLab