Closed jordanbranham closed 2 years ago
Sorry this took me a few days!
You can't configure the exact number of sections for the scalebar, but you can configure how wide it is using width_hint
:
library(ggspatial)
cities <- data.frame(
x = c(-63.58595, 116.41214),
y = c(44.64862, 40.19063),
city = c("Halifax", "Beijing")
)
ggplot(cities) +
geom_spatial_point(aes(x, y), crs = 4326) +
annotation_scale(width_hint = 0.6) +
coord_sf(crs = 3995)
I believe the ggsn package has an option to make a scalebar with a fixed length if you need that behaviour!
No worries! I appreciate the response. Would it be possible (or complicated) to add this as a feature request for a future version? (I'm pretty new to using Github so let me know if this should go elsewhere) I've explored ggsn previously but have found it a bit more unwieldy, and it doesn't appear to be updated as often. If not, no worries of course -- I can see there's already a lot of changes on tap with the ggplot update. Either way, appreciate all your work providing and maintaining ggspatial!
I've been putting development focus elsewhere for the time being to support cleaner code to back up the scalebar and map tiling, so it's unlikely it'll make it as a feature soon!
Hi there, I noticed there's an open issue somewhat, but not exactly, related to this: is there a way to specify the number of black and white bar segments with annotation_scale() (or alternatively, the number of tick marks)? Or is this dependent on a specification elsewhere within one's ggplot code? I haven't been able to track down any documentation or prior questions about this. My default 'bar' style scale bar has 5 sections, 3 black and 2 white. I'd like to create a scalebar that looks like the one depicted in the example on the reference page (annotation-scale.R), with one black and one white section. Let me know if posting an example would be helpful. Thank you!