library(ggplot2)
nc <- sf::st_read(system.file("shape/nc.shp", package = "sf"), quiet = TRUE)
make_demo <- function(...) {
ggplot(nc) +
geom_sf(fill = "grey95", colour = "grey85") +
# For a filled frame, we want to interleave it between the base layer
# (above this line) and the target layer (below the following line).
geom_inset_frame(target.aes = list(fill = "white")) +
geom_sf_inset(map_base = "none") +
coord_sf_inset(inset = configure_inset(...)) +
theme_void()
}
rectangle <- shape_rectangle(sf::st_centroid(nc[21,]), hwidth = 50, hheight = 40)
make_demo(rectangle, scale = 3, translation = c(-300, 0))
make_demo(rectangle, scale = 3, translation = c(-250, -200))
make_demo(rectangle, scale = 3, translation = c(-150, -100))
make_demo(rectangle, scale = 3, translation = c(0, 0))
make_demo(rectangle, scale = 0.5, translation = c(0, 0))
Run the code above in your browser using DataLab