I would like to split the legend of a tmap object, so that one of the two elements is in the top left, and one in the top right. I have been through the documentation of tm_legend, but could not find any hint towards that.

The only thing I can imagine is to plot the two legends separately manually, but it would imply to always know the breaks used for each element and it would not be automatic.

Another solution would be to not split the legend and display it on the side, but I would like to gain some space on the figure and display the legend where there are gaps in the maps displayed.

I have copied a MWE from this webpage.


data(World, metro, land)

## tmap mode set to plotting
tm_shape(land) +
  tm_raster("elevation", palette = terrain.colors(10)) +
  tm_shape(World) +
  tm_borders("white", lwd = .5) +
  tm_text("iso_a3", size = "AREA") +
  tm_shape(metro) +
  tm_symbols(col = "red", size = "pop2020", scale = .5)

What would be an efficient way of plotting the two legend elements separately?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.