tm_add_legend in interactive mode
Hi,
Can one use tm_add_legend with type = "line" in interactive mode? For me it does not seem to work. For type = "fill" it works perfectly:
`library("sf") library("tmap") library(spData)
belgium <- world[world$name_long == "Belgium", ] tmap_mode('plot') tm_shape(belgium) + tm_borders(col ="red", lwd = 2) + tm_add_legend(type = "line", col ="red", lwd = 2, labels = "border")
tmap_mode('view') tm_shape(belgium) + tm_borders(col ="red", lwd = 2) + tm_add_legend(type = "line", col ="red", lwd = 2, labels = "border") tm_shape(belgium) + tm_borders(col ="red", lwd = 2) + tm_add_legend(type = "fill", col ="red", labels = "border")`
Wim
Legend types other the fill (also used for polygons and raster colors) are not implemented in leaflet. I am also waiting a while for this to happen...
Works in tmap v4:
library(sf)
library(tmap)
library(spData)
belgium <- world[world$name_long == "Belgium", ]
tmap_mode('plot')
tm_shape(belgium) + tm_borders(col ="red", lwd = 2) +
tm_add_legend(type = "lines", col ="red", lwd = 2, labels = "border")
tmap_mode('view')
tm_shape(belgium) + tm_borders(col ="red", lwd = 2) +
tm_add_legend(type = "lines", col ="red", lwd = 2, labels = "border")
tm_shape(belgium) + tm_borders(col ="red", lwd = 2) +
tm_add_legend(type = "polygons", col ="red", labels = "border")