Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 204824

R tmap how to show only 1 legend

$
0
0

I have this script that draw a wkt file, how to show only 1 legend not two

library(sf)
library(tmap)
dataset= read.csv('https://raw.githubusercontent.com/djouallah/loadRobjectPBI/master/wkt/wkt.csv')
dataset <- dataset[c("geometry","color","status","labels")]
dataset$color <- as.character(dataset$color)
map <- st_as_sf(dataset, wkt="geometry",crs = 4326)
chartlegend <-     unique(dataset[c("status","color")])
chartlegend <-  chartlegend[order(chartlegend$status),]
rm(dataset)
tm_shape(map)+tm_lines(col="color",lwd = 3.5)+tm_symbols(col = "color", size = 0.06,shape=15)+tm_text(text="labels",col="white")+
rm(map)+
tm_add_legend(type='fill',labels=chartlegend$status, col=chartlegend$color)+
tm_layout(frame = FALSE,bg.color = "transparent",legend.width=2)+
tm_legend(position=c("right", "top"),text.size = 1.3)+
rm(chartlegend)

enter image description here


Viewing all articles
Browse latest Browse all 204824

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>