2

I'm working on a map with tmap and i'm having some trouble changing labels in view mode as in here.

I'm trying to change it to cities names column using name argument like:

tm_shape(mymap, name = "city_name") +
  tm_polygons("Inad", palette = "Reds", title = "")

but it keeps showing the first column as label, which is cities codes (320120 for example).

Is name the right argument to accomplish so?

Alberson Miranda
  • 1,248
  • 7
  • 25

2 Answers2

3

You can use the id argument:

 tm_shape(mymap) + tm_polygons("Inad", id="city_name" palette="Reds", title="")
zaphoid
  • 98
  • 7
0

The following is likely to do the trick:

tm_shape(mymap) +
  tm_text(text = name_var_in_your_shapefile)

If you supply a sample link or other way for replicating, we can test it out. For documentation on tm_text have a look here

Fons MA
  • 1,142
  • 1
  • 12
  • 21
  • Didn't work. I've got Error: Incorrect data variable used for the text when inputing shapefile's names column. Btw, tm_text supposed to print text over the plot all the time, right? Anyway, i just changed columns order, so it's done. – Alberson Miranda Jan 24 '19 at 00:07