Open utterances-bot opened 8 months ago
You can use a bbox to set the limits within coord_sf
:
bbox <- st_bbox(johnston_obs)
ggplot() +
geom_sf(data = nc) +
geom_sf(data = johnston_obs, color = "red") +
coord_sf(
xlim = c(bbox[["xmin"]], bbox[["xmax"]]),
ylim = c(bbox[["ymin"]], bbox[["ymax"]]),
)
Mike Mahoney - Adding context to maps made with ggplot2
How to set the extent of a map based upon a single layer.
https://www.mm218.dev/posts/2023-10-31-map-context/index.html