ggspatial icon indicating copy to clipboard operation
ggspatial copied to clipboard

annotation_scale specified in map units

Open rnuske opened this issue 6 years ago • 5 comments

Would it be possible to have a parameter similar to tmap's tm_scale_bar(breaks=c(0, 100), ...) to tell annotation_scale() to draw only one section instead of the black-white pattern?

A nice side effect could be to provide control over the size for the scale bar in map units. Although, that is probably a separate feature wish.

rnuske avatar Jul 01 '19 21:07 rnuske

I think you can do bar_cols = "black"! Is this what you mean:

library(ggplot2)
library(ggspatial)

load_longlake_data() 

ggplot() +
  layer_spatial(longlake_depthdf) +
  annotation_scale(bar_cols = "black")

Created on 2019-07-01 by the reprex package (v0.2.1)

paleolimbot avatar Jul 02 '19 02:07 paleolimbot

The control over the exact width of the scalebar in map units is indeed a separate feature...I think there are other packages that allow this. I have it parameterized aswidth_hint, which is a number between 0 and 1 that is the suggested proportion of the plot width.

paleolimbot avatar Jul 02 '19 02:07 paleolimbot

I ended up with bar_cols='gray30', line_col='gray30' which looks okay. Saving the map to pdf, this will still be 5 rectangles. Compared to the amount of vertices in the rest of the map this wont matter that much datawise.

rnuske avatar Jul 02 '19 07:07 rnuske

yep, in tmap, for instance, one can specify the exact width of the scale bar in map units. But I couldn't find a way in tmap to put the text ('100 m') right or left of the bar.

I need to do 25 map all having a similar but not exactly the same scale All shall have a scale bar of the same length in map units to make the small differences in scale obvious. So, in my humble opinion specifying the size of the scale bar in map units would be a great addition to ggspatial.

rnuske avatar Jul 02 '19 07:07 rnuske

I think that the scalebar code should be rewritten to use better breaks functions as well...this issue is a good reminder that the scalebar code needs a bit of work.

paleolimbot avatar Jul 02 '19 14:07 paleolimbot