Is there a way to prevent overlapping values in legends in tmap dynamically?
Take this example:
library(tmap)
data("World")
tm_shape(World) +
tm_polygons("HPI", n=7)
The legend does not make it clear what category values of 15, 20, 25, 30, 35 or 40 belong to.
One solution would be this:
tm_shape(World) +
tm_polygons("HPI", n=7,
labels = c("0 to 15", ">15 to 20", ">20 to 25", ">25 to 30", ">30 to 35", ">35 to 40", ">40 to 45"))
However, you will obviously have to change this manually every time you have different n
values for the number of categories.
Can a similar output be generated automatically no matter how categories are used in a map?