3

I am trying to make a map with the cool tmap package and I cannot figure it out how to adjust the legend frame line width. I checked the impressive list of tm_layout arguments, but the closest I found was frame.lwd However,that refers to the frame of the map. I took the guess with legend.frame.lwd but that is not defined. Here is a toy example:

library(tmap)
data(Europe)

tm_shape(Europe) +
  tm_polygons("well_being", textNA="Non-European countries", title="Well-Being Index") +
  tm_text("iso_a3", size="AREA", root=5) +
  tm_layout(legend.position = c("RIGHT","TOP"),
            legend.frame = TRUE,
            frame.lwd = 5) # legend.frame.lwd does not exist

enter image description here

Valentin_Ștefan
  • 6,130
  • 2
  • 45
  • 68
  • If you need a quick solution and you don't need to do it dynamically. You can save as pdf and use `inkscape` – Andre Elrico Feb 20 '18 at 15:09
  • Hi @AndreElrico. I would be curious about an `R/tmap` solution. But, indeed, I keep Inkscape as a viable option. – Valentin_Ștefan Feb 20 '18 at 15:26
  • 1
    As far as I know, this isn't possible. You can [open an issue on GitHub](https://github.com/mtennekes/tmap/issues) with a request to add this functionality. – Jaap Feb 20 '18 at 15:42
  • Thanks for the suggestion @Jaap. It is now an [open issue here](https://github.com/mtennekes/tmap/issues/174) – Valentin_Ștefan Feb 20 '18 at 21:36

1 Answers1

1

In the newer versions of tmap, the argument legend.frame.lwd was included with this commit. Here is an example, using tmap version 2.2:

library(tmap)
data("World")

tm_shape(World) +
  tm_polygons("HPI") +
  tm_layout(legend.frame = TRUE,
            frame.lwd = 5,
            legend.frame.lwd = 5)

enter image description here

Valentin_Ștefan
  • 6,130
  • 2
  • 45
  • 68