1

I have a tmap plot with two layers, a tm_polygon and a tm_borders. A minimal example would be

library(tmap)
library(sf)
library(tidyverse)

data("World")

continents <- World %>% 
  group_by(continent) %>% 
  summarise()

tm_shape(World) +
  tm_polygons(col = "economy") +
tm_shape(continents) +
  tm_borders(col = "red")

To the legend that is automatically created (explaining the fill colors of the first layer) I would like to add a field indicating what the red borders from the second layer stand for (e.g. using a white square with a red border and an appropriate label).

Is there any way to achieve this? Specifying the fill/border colors manually would be sufficient in my case because the number of legend items is small.

dufei
  • 2,166
  • 1
  • 7
  • 18

0 Answers0