Plot a waffle layer.

waffleLayer(
x,
var,
cellvalue,
cellsize,
cellrnd = "ceiling",
celltxt = paste0("1 cell = ", cellvalue),
labels,
ncols,
col,
border = "white",
lwd = 0.2,
legend.pos = "bottomleft",
legend.title.txt = "legend title",
legend.title.cex = 0.8,
legend.values.cex = 0.6,
legend.frame = FALSE,
)

## Arguments

x an sf object, a simple feature collection. names of the numeric variable to plot. value of a single cell. Original values are rounded, using cellrnd method, to be expressed as multiple of cellvalue. size of single cell, in map units. rounding method, one of "ceiling", "floor", "round". text that appears under the legend. names that will appear in the legend. number of columns of the waffles a vector of colors. color of the cells borders. cells borders width. 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)). If legend.pos is "n" then the legend is not plotted. title of the legend. size of the legend title. size of the values in the legend. whether to add a frame to the legend (TRUE) or not (FALSE). whether to add the layer to an existing plot (TRUE) or not (FALSE).

## Examples

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,