View source: R/inset_shape_circle.R
shape_circle | R Documentation |
Circular insets
shape_circle(centre, radius)
centre |
Coordinates of the inset centre. Ideally this should be an
|
radius |
Radius of the inset circle in the units of the inset's |
A shape definition suitable for use with configure_inset()
.
configure_inset()
Other shapes:
shape_rectangle()
,
shape_sf()
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()
}
circle <- shape_circle(sf::st_centroid(nc[21,]), radius = 50)
make_demo(circle, scale = 3, translation = c(-200, -200))
make_demo(circle, scale = 3, translation = c(-100, -100))
make_demo(circle, scale = 3, translation = c(0, 0))
make_demo(circle, scale = 0.5, translation = c(0, 0))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.