如何将地图标题放在面板之外(tmap 包)

How to put title of a map outside of the panel (tmap package)

我正在用 R 绘制一张简单的地图,但遇到了这个问题:标题与绘图重叠,我不知道如何将它放在面板之外。

使用 ggplot2,我可以使用 theme 函数中的 plot.title.position 选项轻松完成此操作,因为 tmap 使用相同的逻辑,我认为这可能是一种方法。

代码和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"
    )

使用 tm_layout(main.title = "Main Title", main.title.position = "center") 代替 tm_layout(title = "The quick brown fox jumps over the lazy dog") 使标题位于地图之外。

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")