The gridExtra
package
provides a basic implementation of regular polygons,
ngonGrob()/grid.ngon
, and a convenience function to draw
ellipses, ellipseGrob()/grid.ellipse()
. We illustrate below
the basic usage of these vectorised functions.
library(gridExtra)
library(grid)
library(grid)
N <- 5
xy <- polygon_regular(N)*2
# draw multiple polygons
g <- ngonGrob(unit(xy[,1],"cm") + unit(0.5,"npc"),
unit(xy[,2],"cm") + unit(0.5,"npc"),
n=seq_len(N)+2, gp=gpar(fill=1:N))
grid.newpage()
grid.draw(g)