How could I go about placing a map scale bar (currently made with ggspatial's annotation_scale()
) outside of the map area, and with the legend.
Here is ggspatial's reprex for the function, with color added in so we have a legend:
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() +
coord_sf(crs = 3995)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, color = x), crs = 4326) +
annotation_scale() +
coord_sf(crs = 3995)
I've looked into using cowplot with its get_plot_component()
, but the scale bar isn't one of the components.