annotation_spatial_hline {ggspatial} | R Documentation |
Projected horizontal and vertical lines
Description
Projected horizontal and vertical lines
Usage
annotation_spatial_hline(
mapping = NULL,
data = NULL,
stat = "identity",
...,
intercept = waiver(),
limits = NULL,
detail = 100,
crs = NULL,
na.rm = FALSE,
show.legend = NA
)
annotation_spatial_vline(
mapping = NULL,
data = NULL,
stat = "identity",
...,
intercept = waiver(),
limits = NULL,
detail = 100,
crs = NULL,
na.rm = FALSE,
show.legend = NA
)
GeomSpatialXline
Arguments
mapping |
An aesthetic mapping created with |
data |
A data frame or other object, coerced to a data.frame by |
stat |
Statistical transformation to use on this layer. See |
... |
Passed to the combined stat/geom as parameters or fixed aesthetics. |
intercept |
The x or y value that should be constant in the given
|
limits |
Use |
detail |
The number of points that should be used when converting the line into segments. |
crs |
The crs of the x and y aesthetics, or NULL to use default lon/lat crs (with a message). |
na.rm |
Should missing aesthetic values be removed? |
show.legend |
Should the legend be shown? |
Format
An object of class GeomSpatialXline
(inherits from GeomHline
, Geom
, ggproto
, gg
) of length 4.
Examples
cities <- data.frame(
x = c(-63.58595, 116.41214, 0),
y = c(44.64862, 40.19063, 89.9),
city = c("Halifax", "Beijing", "North Pole")
)
p <- ggplot(cities, aes(x, y, label = city)) +
geom_spatial_point(crs = 4326) +
# view of the north pole
coord_sf(crs = 3995)
p +
# longitude lines
annotation_spatial_vline(
intercept = seq(-180, 180, by = 10),
crs = 4326
) +
# latitude lines
annotation_spatial_hline(
intercept = seq(0, 90, by = 10),
crs = 4326
)