oswaldosantos / ggsn

R package to add north symbols and scale bars to maps created with ggplot or ggmap
http://oswaldosantos.github.io/ggsn/
GNU General Public License v2.0
161 stars 8 forks source link

scalebar on all facets #30

Closed statnmap closed 5 years ago

statnmap commented 6 years ago

If I want to keep the scalebar on all facets, text appears in a weird way:

library(ggsn); library(sf)
dsn <- system.file('extdata', package = 'ggsn')

# Map in geographic coordinates
map <- st_read(dsn, 'sp', quiet = TRUE)

(ggm1 <- ggplot(map, aes(fill = nots)) +
    geom_sf() +
    scale_fill_brewer(name = 'Animal abuse\nnotifications', palette = 8))

ggm1 +
  blank() +
  facet_grid(~nots) + 
  north(map) +
  scalebar(map, dist = 5, dd2km = TRUE, model = 'WGS84')

facets

oswaldosantos commented 6 years ago

Please, try with ggsn v0.4.10:

ggm1 +
  blank() +
  facet_grid(~nots) + 
  north(map) +
  scalebar(map, dist = 5, dd2km = TRUE, model = 'WGS84', facet.var = 'nots')