【R】mapsf : inset map

こちらで書いた、mapsfに関して、Inset mapの紹介があったのでやってみた。

基本的に、mf_inset*()関数でインセットするらしい。

library(mapsf)

mf_theme("default", mar = c(0,0,0,0))
mtq <- mf_get_mtq()
mtq_target <- mtq[c(10),]
mf_map(mtq)
mf_map(mtq_target, add = TRUE, col = "tomato")
mf_inset_on(x = mtq_target, pos = "topright", cex = .2)
mf_map(mtq_target, add = FALSE, col = "tomato")
mf_inset_off()

各県名を表示したラベルマップの例

mtq <- mf_get_mtq()
theme1 <- list(
  name = "theme1", 
  bg = "darkblue", 
  fg = "darkgreen", 
  mar = c(0, 0, 0, 0), 
  tab = TRUE, 
  pos = "left", 
  inner = TRUE, 
  line = 0.5, 
  cex = .5, 
  font = 2
)
mf_theme(theme1)
mf_map(mtq, col = "#e4e9de", border = "red")
mf_label(
  x = mtq, 
  var = "LIBGEO", 
  col = "black", 
  cex = 0.8, 
  font = 6,
  halo = TRUE, 
  bg = "white", 
  r = 0.1, 
  overlap = FALSE, 
  lines = FALSE
)
mf_layout(title = "Municipalities of Martinique", 
          credits = paste0("Sources: Insee and IGN, 2018\n",
                           "mapsf ", 
                           packageVersion("mapsf")), 
          arrow = FALSE)
mf_arrow(pos ='topright')

Add a Comment

メールアドレスが公開されることはありません。