tmap
tmap copied to clipboard
border.col in tm_add_legend does not take in a vector
Hi tmap team,
I have the following example codes. The issue I ran into is that border.col does not take in a vector like other aesthetics variables in tm_add_legend. You can see an example output image below for the codes. You can see that the thinner/second polygon's border color did not change even though I pass in two values, while other lwd and labels are fine. I would like to have that functionality and this should be easy to change. Many thanks in advance!!
tmap_mode('plot')
data(World)
tm_shape(World) +
tm_polygons(alpha=0) +
tm_add_legend('fill', labels=c('a', 'b'), alpha=0, border.col=c('red', 'blue'), border.lwd=c(3,1))
Thanks for reporting this.
It should be a relatively easy fix, but it has low priority for me to be honest. PRs are welcome. It is this code chunk that needs to be improved: https://github.com/r-tmap/tmap/blob/master/R/plot_legend_prepare.R#L38-L60
It works for symbols though
data(World)
tm_shape(World) +
tm_polygons(alpha=0) +
tm_add_legend('symbol', labels=c('a', 'b'), alpha=0, border.col=c('red', 'blue'), border.lwd=c(3,1))