View source: R/stat_sf_coordinates_inset.R
| geom_sf_text_inset | R Documentation |
Reduce spatial data to coordinates in the same way as stat_sf_coordinates().
The result can then be used by geom_sf() or
geom_sf_inset() or any geom that needs x and
y aesthetics. As this is particularly useful for text, wrappers are
provided for geom_text() and geom_label().
geom_sf_text_inset(
mapping = aes(),
data = NULL,
stat = "sf_coordinates_inset",
position = "identity",
...,
where = "inset",
parse = FALSE,
check_overlap = FALSE,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE,
fun.geometry = NULL
)
geom_sf_label_inset(
mapping = aes(),
data = NULL,
stat = "sf_coordinates_inset",
position = "identity",
...,
where = "inset",
parse = FALSE,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE,
fun.geometry = NULL
)
stat_sf_coordinates_inset(
mapping = ggplot2::aes(),
data = NULL,
geom = "point",
position = "identity",
...,
inset = NA,
fun.geometry = NULL,
where = "inset",
na.rm = TRUE,
show.legend = NA,
inherit.aes = TRUE
)
mapping, data, geom, position, na.rm, show.legend, inherit.aes, fun.geometry, ... |
See |
stat, parse, check_overlap |
See |
where |
Specifies how the text position interacts with the inset.
|
inset |
Inset configuration; see |
A plot layer
The sf geometry column containing spatial features
X dimension of the simple feature
Y dimension of the simple feature
X dimension of the simple feature after inset transformation
Y dimension of the simple feature after inset transformation
logical indicating points inside the inset viewport
1 for points outside the inset, otherwise the configured inset scale parameter
library(ggplot2)
nc <- sf::st_read(system.file("shape/nc.shp", package = "sf"), quiet = TRUE)
ggplot(nc) +
geom_sf_inset() +
geom_inset_frame() +
geom_sf_text(
aes(x = after_stat(x_inset), y = after_stat(y_inset), label = NAME),
stat = "sf_coordinates_inset") +
coord_sf_inset(configure_inset(
shape_circle(
centre = sf::st_sfc(sf::st_point(c(-80, 35.5)), crs = 4326),
radius = 50
),
scale = 1.5, translation = c(-50, -140), units = "mi"
))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.