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

Option to change number of labels from 3 to 2 in scalebar #51

Open Tom-Jenkins opened 4 years ago

Tom-Jenkins commented 4 years ago

Hi Oswaldo, the scalebar function is great, but I was wondering if there is currently a way to change the number of labels (i.e. the number of scales), ideally from 3 to 2 whereby only "0" and the maximum scale is drawn. For example, on the map below only display 0 and 8km. This would be useful because sometimes in small scales the middle label isn't required and gets in the way.

Example

library(ggsn); library(ggplot2); library(sf)
data("domestic_violence")
(ggm1 <- ggplot(domestic_violence, aes(fill = Scaled)) +
geom_sf() +
scale_fill_continuous(low = "#fff7ec", high = "#7F0000"))
ggm1 + north(domestic_violence) + scalebar(domestic_violence, dist = 4, dist_unit = "km", transform = TRUE, model = "WGS84")

example_map