【问题标题】:tmap:: faceted animated map: How to suppress title when custom label giventmap:: 多面动画地图:给定自定义标签时如何抑制标题
【发布时间】:2019-06-19 11:47:14
【问题描述】:

我使用 tmap:: tm_facets 和自定义面板标签创建了一个动画多面图。如何避免用于分面的参数显示为附加标题?我只想要面板中的自定义标签。

最小示例:

rm(list=ls(all=TRUE)) 
library(tmap)
library(spData)

urb_anim = tm_shape(world) + tm_polygons() + 
  tm_shape(urban_agglomerations) + tm_dots(size = "population_millions") +
  tm_facets(along = "year", free.coords = FALSE) +
  tm_layout(panel.labels = c("custom label1", "custom label2")) 

这给了我以下结果:

当我尝试从此处重现动画地图的示例时:https://geocompr.robinlovelace.net/adv-map.html 我也没有像示例中那样在面板中获得标题,而是在左上角的绘图之外。

【问题讨论】:

    标签: animation gif facet tmap


    【解决方案1】:

    我自己找到了答案:

    在设置 ncol =1 和 nrow = 1 并使用 tmap_animation 保存创建的地图时,使用 by 而不是带有 tm_facets 的沿参数对我有用。所以代码应该是:

    urb_anim = tm_shape(world) + tm_polygons() + 
      tm_shape(urban_agglomerations) + tm_dots(size = "population_millions") +
      tm_facets(by = "year", free.coords = FALSE, ncol=1, nrow=1) +
      tm_layout(panel.labels = c("custom label1", "custom label2"))
    

    【讨论】:

    • 你能把最终结果添加为图像吗?目前尚不清楚您的目标是什么,即您设法解决了什么问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多