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 9 forks source link

change color #38

Closed math-ch closed 6 years ago

math-ch commented 6 years ago

I'd like to change border size and colors of the scalebar. I thought it would be possible to add "color", "fill" and "border.size" arguments to the code, unfortunately it s not. Any pointers?

oswaldosantos commented 6 years ago
library(ggsn); library(sf)
dsn <- system.file('extdata', package = 'ggsn')
map <- st_read(dsn, 'sp')

ggplot(map, aes(fill = nots)) +
  geom_sf() +
  scalebar(map, , dist = 5, dd2km = TRUE, model = 'WGS84',
           box.color = "red", box.fill = "blue", border.size = .3)
math-ch commented 6 years ago

Currently working with R 3.5 - I tried to add in the code:

box.color = "red", box.fill = "blue", border.size = .3

But i get the following error message:

"Error in scalebar(data = NULL, dist = 100, dd2km = TRUE, model = "WGS84",  : 
  unused arguments (box.color = "red", box.fill = "blue", border.size = 0.3)"

Without the arguments "color" and "border", the following code works fine:

mapaFR <- raster::getData("GADM", country="France", level=2)
ggplot()+
  geom_polygon(data = mapaFR, aes(x=long, y = lat, group = group), fill="transparent", colour = "black", size=0.2) + 
  #geom_sf() +
  scalebar(data=NULL, dist = 100, dd2km = TRUE, model = 'WGS84',
         x.min = -3.143751, x.max = -0.5, y.min = 42.5, y.max = 44,
         st.size = 3, height=0.05, st.dist=0.1)
oswaldosantos commented 6 years ago

You must use ggsn v0.4.11

math-ch commented 6 years ago

yes working with this version! thanks!