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()
.
Dear Giraud,
Thank you so much!
This helps a lot.
Warm regards,
…On Tue, May 11, 2021 at 11:48 AM Timothée Giraud ***@***.***> wrote:
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")
<https://camo.githubusercontent.com/9ad3436c12550844e1ef6bc3e4f001d79437b874856318655e48a5a9da72c23a/68747470733a2f2f692e696d6775722e636f6d2f466e6d4d6f6f352e706e67>
par(opar)
Created on 2021-05-11 by the reprex package <https://reprex.tidyverse.org>
(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:
<https://camo.githubusercontent.com/a067cc3ee0f6ff40b73f05d1b8adacc30d8197a07fb8eb0bf88c3ede72ea698c/68747470733a2f2f7062732e7477696d672e636f6d2f6d656469612f45696d7636547158304149565537453f666f726d61743d706e67266e616d653d736d616c6c>
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#18 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AN2D3YKTLVA4UB773KZDH7DTNDVN3ANCNFSM44ULODJQ>
.
--
*Oluoch, Wyclife Agumba*
*+254729371248*
*+4915217742479*
***@***.*** ***@***.***>*
***@***.*** ***@***.***>*
*Profession: EARTH SCIENTIST*
*Interests*: Plant Ecology, Species Distribution Modeling,
Ethnobotany, Remote Sensing & GIS, Machine Learning, Climate Change
*"...stumbling, falling, and rolling forward, leave me with scars, but,
reduce the distance to my destination..."*