xmax <- 100
ymax <- 100
rmin <- 10
rmax <- 20
N <- 20
## Random centre coordinates and radii
layout <- data.frame(id = 1:N,
x = runif(N, 0, xmax),
y = runif(N, 0, ymax),
radius = runif(N, rmin, rmax))
## Get data for circle vertices
verts <- circleLayoutVertices(layout, idcol=1, xysizecols=2:4,
sizetype = "radius")
if (FALSE) {
library(ggplot2)
## Draw circles annotated with their IDs
ggplot() +
geom_polygon(data = verts, aes(x, y, group = id),
fill = "grey90",
colour = "black") +
geom_text(data = layout, aes(x, y, label = id)) +
coord_equal() +
theme_bw()
}
Run the code above in your browser using DataLab