如何将 tmap 包中地图的标题放在面板外部

7
我正在R中绘制一个简单的地图,但遇到了问题:标题与图形重叠在一起,我不知道该如何将其放置在面板外部。

brasil

使用ggplot2中的plot.title.position选项在theme函数中可以轻松实现此操作,由于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"
    )
1个回答

12

使用tm_layout(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")

在这里输入图片描述


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接