6

I'm plotting a simple map in R and I'm stuck with this problem: the title is overlapping the plot and I don't know how to put it outside of the panel.

brasil

With ggplot2 I can do this easily with plot.title.position option in theme function, since tmap works with the same logic, I think might be a way to do this.

Code and shapefile download:

library(sf)
library(tmap)

brasil <- st_read("/shp/BRUFE250GC_SIR.shp")

tm_shape(brasil) +
    tm_borders() +
    tm_fill() +
    tm_compass() +
    tm_scale_bar() +
    tm_layout(
        title = "The quick brown fox jumps over the lazy dog"
    )
Rik Ferreira
  • 161
  • 1
  • 10

1 Answers1

12

Use tm_layout(main.title = "Main Title", main.title.position = "center") in place of tm_layout(title = "The quick brown fox jumps over the lazy dog") to have the title outside the map.

tm_shape(brasil) +
  tm_borders() +
  tm_fill() +
  tm_compass() +
  tm_scale_bar() +
  tm_layout(
    main.title = "The quick brown fox jumps over the lazy dog", 
    main.title.position = "center")

enter image description here

UseR10085
  • 7,120
  • 3
  • 24
  • 54