library(tmap)
#> Warning: multiple methods tables found for 'area'
data(metro)
metro$group = as.factor(sample(1:5, size = nrow(metro), replace = TRUE))
# two legends
tm_shape(metro) +
tm_symbols(col = "group", shape = "group")
# one legend
tm_shape(metro) +
tm_symbols(col = "group", shape = "group",
legend.col.show = FALSE, legend.shape.show = FALSE) +
tm_add_legend(type = "symbol", col = RColorBrewer::brewer.pal(5, "Set3"),
shape = 21:25, labels = sort(unique(metro$group)))
Created on 2022-07-05 by the reprex package (v2.0.1)
tmap4:
Created on 2022-10-04 with reprex v2.0.2