1

我目前正在尝试在同一张地图上显示不同变量的值。

下面是我的代码:

tm_shape(pv_malay_merge) + 
  tm_fill(col = "Exposure", n = 10, title = "Policyholders' Exposure",
          palette = rev(brewer.pal(n = 4, "RdYlGn"))) +
  tm_borders(lwd = 0.5) +
  tm_text(text = "NAME_1", size = 0.5) +
  tm_shape(malay_merge) +
  tm_bubbles(size = "Exposure")

上面的代码导致:

马来西亚地图

之后,我尝试将其更改为:

tm_shape(pv_malay_merge) + 
  tm_fill(col = "Exposure", n = 10, title = "Policyholders' Exposure",
          palette = rev(brewer.pal(n = 4, "RdYlGn"))) +
  tm_borders(lwd = 0.5) +
  tm_text(text = c("NAME_1", "Exposure"), size = 1) +
  tm_shape(malay_merge) +
  tm_bubbles(size = "Exposure")

注意tm_text()功能的变化。这导致:

显示不同值的两张马来西亚地图

关于组合地图的任何建议?

4

1 回答 1

2

You cannot have more than one tm_text layers in one group, so you need two layer groups, e.g.:

tm_shape(pv_malay_merge) + 
  tm_text(text = "NAME_1", size = 0.5) +
tm_shape(pv_malay_merge) + 
  tm_text(text = "Exposure", size = 0.5)

To prevent occlusion, you could use ymod for one of them, as already suggested.

Why are the bubbles not visible? They should work better than text labels imo.

于 2016-12-16T20:24:39.610 回答