Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Plotting legend only in tmap

Tags:

r

gis

tmap

I have a crowded map I've generated using the tmap library, I've turned the legend off with the argument legend.show = FALSE in the tm_layout() function.

What I want to know is the following: is there a way to generate a legend for this map on its own? So that it could be a stand alone image?

(I'm sorry the code won't give you a map)

tm_borders()+
tm_shape(parks)+
  tm_polygons()+
tm_shape(houses)+
  tm_polygons()+
tm_shape(grid)+
    tm_polygons(col="n", style ="cont", palette="plasma",alpha = 0.5)+
tm_layout(legend.show=FALSE)  

EDIT: Yes. It's in the help file and it's this: argument legend.only = TRUE in the tm_layout() function.

  tm_borders()+
    tm_shape(parks)+
      tm_polygons()+
    tm_shape(houses)+
      tm_polygons()+
    tm_shape(grid)+
        tm_polygons(col="n", style ="cont", palette="plasma",alpha = 0.5)+
    tm_layout(legend.only= T)
like image 363
damo Avatar asked Sep 11 '26 03:09

damo


1 Answers

EDIT: Yes. It's in the help file and it's this: legend.only

tm_borders()+
    tm_shape(parks)+
      tm_polygons()+
    tm_shape(houses)+
      tm_polygons()+
    tm_shape(grid)+
        tm_polygons(col="n", style ="cont", palette="plasma",alpha = 0.5)+
    tm_layout(legend.only= T)
like image 60
damo Avatar answered Sep 13 '26 17:09

damo