【问题标题】:How to change legend position using qtm() in the tmap package如何使用 tmap 包中的 qtm() 更改图例位置
【发布时间】:2018-05-26 07:58:13
【问题描述】:

我创建了一张显示犯罪数字的伦敦地图。正如你从下面的图片中看到的那样——我的传说在一个尴尬的地方——我希望它在左下角还是右下角?任何人都知道我怎么可能做到这一点。我创建地图的代码如下。

另外,我将如何为地图创建标题 - 我已经创建了图例标题。

地图和图例

qtm(brgh, fill = "Theft15", fill.title="Number of recorded thefts")

【问题讨论】:

    标签: r plot maps tmap


    【解决方案1】:

    由于我没有你的数据,我决定使用tmap 包中的数据进行以下演示。关键是使用tm_legend()。如果您查看当前的 CRAN 手册,您可以在 tm_layout() 部分找到更多信息。您可以在tm_legend() 中使用legend.position 指定图例位置。主标题可以在函数中使用main.titlemain.title.position

    library(tmap)
    
    data(World, rivers, metro)
    
    qtm(shp = World, fill = "economy", format = "World", style = "col_blind") +
    tm_legend(legend.position = c("left", "top"),
              main.title = "My title",
              main.title.position = "right")
    

    qtm(shp = World, fill = "economy", format = "World", style = "col_blind") +
    tm_legend(legend.position = c("left", "bottom"),
              main.title = "My title",
              main.title.position = "right")
    

    【讨论】:

      猜你喜欢
      • 2018-04-18
      • 1970-01-01
      • 2021-05-16
      • 2018-01-15
      • 2021-10-04
      • 1970-01-01
      • 1970-01-01
      • 2013-06-29
      • 2020-08-30
      相关资源
      最近更新 更多