【问题标题】:R tmap: How to adjust the legend frame line widthR tmap:如何调整图例框线宽
【发布时间】:2018-07-30 22:55:41
【问题描述】:

我正在尝试使用酷炫的 tmap 包制作地图,但我无法弄清楚如何调整图例框架的线宽。我检查了令人印象深刻的tm_layout 参数列表,但我发现最接近的是frame.lwd 但是,它指的是地图的框架。我用legend.frame.lwd 进行了猜测,但没有定义。这是一个玩具示例:

library(tmap)
data(Europe)

tm_shape(Europe) +
  tm_polygons("well_being", textNA="Non-European countries", title="Well-Being Index") +
  tm_text("iso_a3", size="AREA", root=5) +
  tm_layout(legend.position = c("RIGHT","TOP"),
            legend.frame = TRUE,
            frame.lwd = 5) # legend.frame.lwd does not exist

【问题讨论】:

  • 如果您需要快速解决方案并且不需要动态执行。您可以保存为 pdf 并使用 inkscape
  • 嗨@AndreElrico。我会对R/tmap 解决方案感到好奇。但是,确实,我将 Inkscape 作为一个可行的选择。
  • 据我所知,这是不可能的。您可以open an issue on GitHub 提出添加此功能的请求。
  • 感谢@Jaap 的建议。现在是open issue here

标签: r tmap


【解决方案1】:

tmap 的较新版本中,legend.frame.lwd 参数包含在this commit 中。这是一个示例,使用tmap 2.2 版:

library(tmap)
data("World")

tm_shape(World) +
  tm_polygons("HPI") +
  tm_layout(legend.frame = TRUE,
            frame.lwd = 5,
            legend.frame.lwd = 5)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-10-15
    • 2015-12-29
    • 2019-11-23
    • 2017-11-28
    • 2018-04-06
    • 2019-11-08
    • 2020-12-07
    • 2022-11-11
    相关资源
    最近更新 更多