mapsf icon indicating copy to clipboard operation
mapsf copied to clipboard

Legend outside the map - how does "map units" works ?

Open MayeulDvl opened this issue 1 year ago • 2 comments

Hi ! First, thank you for mapsf, creating maps is such a breeze now.

Currently I'm trying to create a map layout with all the visual elements outside the map zone. I was able to do it for the legend using leg_adj, but I struggle with the north arrow and the scale. How do map units work ? Would it be possible to add an 'adj' parameter to mf_arrow() and mf_scale() ?

Here is a little demo of what I mean : demo_map_layout

library(mapsf)

mtq <- mf_get_mtq()

par(bg = '#4488B8')
mf_theme(mar = c(0,5,0,0), bg = '#FCBD49')
mf_map(mtq, type = 'choro', var = 'POP', leg_pos = 'left', leg_adj = c(-6.7,0))
# works fine, I don't understand why you can adj with a higher number than the margin
# without being outside the plot

mf_arrow(pos = 'bottomleft')  # still inside the map zone, which is exepected behaviour
mf_arrow(pos = c(0,0))  # I don't understand what coordinates you are supposed to use
mf_scale(pos = c(1,1))  # same

MayeulDvl avatar Aug 06 '24 07:08 MayeulDvl

Hello, I'll try to make these parameters more explicit in a next version of the pkg. mar takes lines unit (as in par(mar = ...)). adj uses units specific to the package, this is not very practical. pos uses map units, this means units used by the Coordinates Reference System of the map. You can use locator() to get these coordinates, or use pos = "interactive"

I'll try to make these parameters more explicit in a next version of the pkg.

locator.webm

interactive

rCarto avatar Aug 09 '24 13:08 rCarto

Oh, ok I see. Actually, I will not be able to use "pos" then ; I create my maps in a Rmarkdown with a for loop, so my pos will change everytime. I feel like the philosophy of adjust is the right one, or maybe pos in percentage of the graphical view ? For now I will keep the north arrow inside the map, it will be fine. Thank you for your help !

MayeulDvl avatar Aug 12 '24 06:08 MayeulDvl