How to display the legend only once when using tmap::tm_facets() in view mode?

I made a map using the tmap package. This map is displayed in view mode and has facets . I would like the legend to appear only once, outside of the graph/facets, at the bottom and stacked horizontally.

I cannot share the original data but here is a hopefully reproducible example:

library(tmap)
library(tmaptools)

data(World, NLD_muni, NLD_prov, land, metro)

tmap_mode("view")

map <- tm_shape(NLD_muni) +
  tm_borders() +
  tm_facets(by="province", free.scales = F) +
  tm_fill("population", style="kmeans", convert2density = TRUE) +
  tm_shape(NLD_prov) +
  tm_borders(lwd=4) +
  tm_facets(by="name") +
  tm_legend(legend.outside = T, legend.stack = "horizontal", legend.outside.position = 'bottom')
map

You can see in tm_legend() what I have already tried, to no avail. Would anybody have any pointers?

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.