简体   繁体   中英

How to adjust the compass position on the map in R

I would like to adjust the compass position on the map. Note that part of the compass is joined to the scale, however, I would like to leave the compass slightly above the scale.

library(terra)
library(geodata)
library(tmap)
library(sf)

brz <- geodata::gadm("Brazil", level=2, path=".")
mun <- brz[brz$NAME_2 == "Castro", ]

tm_shape(sf::st_as_sf(mun)) +
tm_borders() +
tm_scale_bar(position = c("LEFT", "BOTTOM"))+
tm_compass(size = 3, cardinal.directions = c("N", "E", "S", "W"), type = 'rose', position = c("left","BOTTOM"),show.labels = 2) 

在此处输入图像描述

library(terra)
library(geodata)
library(tmap)
library(sf)

brz <- geodata::gadm("Brazil", level=2, path=".")
mun <- brz[brz$NAME_2 == "Castro", ]

tm_shape(sf::st_as_sf(mun)) +
tm_borders() +
tm_scale_bar(position = c("LEFT", "BOTTOM"))+
tm_compass(size = 3, cardinal.directions = c("N", "E", "S", "W"), type = 'rose', position = c(0.15,0.135),show.labels = 2) 

You can use numbers instead of left and bottom. But you have to save insert the number

Instead of position = c("LEFT","BOTTOM") change it to numbers position = c(0.15, 0.135)

But you have to self look how exactly you want it. The first number show x-position and the second y-position

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM