1

I am currently trying to show the values of different variables on the same map.

Below is my code:

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")

The code above results in:

Malaysia map

After that I try to change it to:

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")

Notice the change in tm_text() function. This results in:

two Malaysia maps showing different values

Any suggestion on combining the maps?

Jaap
  • 81,064
  • 34
  • 182
  • 193
Hardian Lawi
  • 588
  • 5
  • 22
  • Including both into one map, would make the map hard to read imo. Furthermore: a [reproducible example](http://stackoverflow.com/questions/5963269) would make it a lot easier for others to help you. – Jaap Dec 14 '16 at 09:03
  • btw: maybe try with two separate calls for `tm_text`? – Jaap Dec 14 '16 at 09:07
  • @ProcrastinatusMaximus The values will overlap with each other if we separate `tm_text`, I have tried it previously by creating two layers – Hardian Lawi Dec 15 '16 at 00:37
  • You can use the `xmod` and the `ymod` parameters to adjust the position of the labels. – Jaap Dec 15 '16 at 08:07
  • @ProcrastinatusMaximus Thank you for your suggestion! I will try it – Hardian Lawi Dec 21 '16 at 09:20

1 Answers1

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.

Martijn Tennekes
  • 1,951
  • 13
  • 19