riatelab / mapsf

Thematic cartography with R

Home Page:https://riatelab.github.io/mapsf

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Map axes labels

Wycology opened this issue · comments

Hi, I can't find a way to include axes labels around the maps created by mapsf package. Could you please suggest a workaround. Thanks!

Hello,
It is indeed possible:

library(mapsf)
#> Le chargement a nécessité le package : sf
#> Linking to GEOS 3.7.1, GDAL 3.1.2, PROJ 7.1.0
mtq <- mf_get_mtq()
# define a theme with sufficent margins to plot the graticules labels
mytheme <- mf_theme("default", mar = c(2,2,1.2,0)+0.5)
# use theme margins
opar <- par(mar = mytheme$mar)
plot(st_geometry(mtq), 
     border = NA, col = NA,
     graticule  = st_crs(4326), 
     axes = TRUE, 
     bg = mytheme$bg,              # use theme bg color
     lon = seq(-62, -60, by = .2), # graticules lon coordinates
     lat = seq(14, 15,   by = .2)  # graticules lat coordinates
)
# add the map
mf_map(mtq, add = TRUE)
mf_title("Map with graticules")

par(opar)

Created on 2021-05-11 by the reprex package (v2.0.0)

BUT, please note that this solution is a bit hacky and does not work in a workflow using mf_init() ot mf_export().

Also, I mostly stand with this statement in sf docs: