Put legend horizontally in tmaps

Viewed 361

I'm doing a map using data("World") and I want to show the legend in the bottom and horizontally. Currently, my map is something like this:

enter image description here

I want something like this: enter image description here

Here is my code:

tm_shape(mundo)+
  tm_borders() + 
  tm_fill("total_vaccinations_per_hundred",
              palette = "Blues",
          title = "",
          breaks = c(0, 0.1, 0.3, 1, 3, 10, 30, 100, 300),
          style = "cont")+ 
  tm_layout(main.title = "Dosis administradas de vacuna contra el COVID-19 por cada 100 personas", 
            main.title.position = "center", main.title.fontface = "bold")

Thanks in advance!

1 Answers

Does this get you where you want to be?

library(tmap)

data("World")

tm_shape(World)+
  tm_borders()+ 
  tm_fill("HPI",
          palette = "Blues",
          title = "",
          breaks = c(0, 0.1, 0.3, 1, 3, 10, 30, 100, 300),
          style = "cont",
          legend.is.portrait = FALSE)+
  tm_layout(legend.outside.position = "bottom",
            legend.outside.size = 0.35,
            legend.outside = TRUE)

Created on 2021-04-07 by the reprex package (v1.0.0)

Related