Home > database >  How to move the compass arrow and scale bar off of the plot when using tmap in R?
How to move the compass arrow and scale bar off of the plot when using tmap in R?

Time:03-02

I am using the tmap package to plot some data on a map. Because of the size of the datasets, enter image description here

CodePudding user response:

You can also use inner margins to place legends and attributes outside.

example

data(World)
qtm(World, 
    fill = "economy")  
    tm_layout(inner.margins = c(0.02, 0.02, 0.02, 0.3))  
    tm_compass(size = 3, type = 'rose')  
    tm_scale_bar(size = 0.5)

(This will be different (easier) in tmap4)

CodePudding user response:

With the packages you have loaded, you can move the compass and scale_bar attributes outside of the map within tm_layout(). I can't quite position it under the legend. I am using the tmap World data here

data(World, rivers, metro)
qtm(World, 
    fill = "economy")  
  tm_layout(legend.outside = T, frame = FALSE, attr.outside=TRUE, attr.position = c(.9, 0) )  
  tm_compass(size = 3, type = 'rose')  
  tm_scale_bar(size = 0.5)

sample map

  • Related