Learn R Programming

ggspatial (version 1.0.2)

annotation_scale: Spatial-aware scalebar annotation

Description

Spatial-aware scalebar annotation

Usage

annotation_scale(plot_unit = NULL, width_hint = 0.25,
  unit_category = c("metric", "imperial"), style = c("bar", "ticks"),
  location = c("bl", "br", "tr", "tl"), bar_cols = c("black", "white"),
  line_width = 1, line_col = "black", height = unit(0.25, "cm"),
  pad_x = unit(0.25, "cm"), pad_y = unit(0.25, "cm"),
  text_pad = unit(0.15, "cm"), text_cex = 0.7, text_col = "black",
  text_face = NULL, text_family = "", tick_height = 0.6)

GeomScaleBar

Arguments

plot_unit

For non-coord_sf applications, specify the unit for x and y coordinates. Must be one of km, m, cm, mi, ft, or in.

width_hint

The (suggested) proportion of the plot area which the scalebar should occupy.

unit_category

Use metric or imperial units.

style

One of "bar" or "ticks"

location

Where to put the scale bar ("tl" for top left, etc.)

bar_cols

Colours to use for the bars

line_width

Line width for scale bar

line_col

Line colour for scale bar

height

Height of scale bar

pad_x, pad_y

Distance between scale bar and edge of panel

text_pad, text_cex, text_col, text_face, text_family

Parameters for label

tick_height

Height of ticks relative to height of scale bar

Value

A ggplot2 layer.

Format

An object of class GeomScaleBar (inherits from Geom, ggproto, gg) of length 4.

Examples

Run this code
# NOT RUN {
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)

# }

Run the code above in your browser using DataLab