I am trying to produce a map using the tmap library. I want to label all areas and use lead lines to label tiny areas. I'm looking for a line of code that works like ggrepel in ggplot2 or geom_sf_label_repel in the sf library but for tmap.
Here is a sample code which shows all labels but no lead lines outside the polygons:
library(tmap)
data(World)
tm_shape(World) + tm_polygons("HPI") + tm_text("name",size=0.4)
THis is the result:
There are overlapping labels that could have been placed in the white spaces with leading lines to the polygons
This is the kind of end result I hope to have where the polygon is too small to show a label correctly:
How do I achieve this with tmap with an actual shapefile?
tmap
. There is an option to manually modify the x and y coordinates of each label with respect to actual location (by passing a vector toxmod
andymod
intm_text
), but I haven't found a way to link those text labels back to their actual location using a line. Maybe that could be a feature suggestion you could make on the package's GitHub? – Zoarah