Joins the points of each group into a closed shape, in data order. Map group when the data holds several polygons.

geom_polygon(
  mapping = NULL,
  data = NULL,
  color = NULL,
  alpha = NULL,
  linewidth = NULL,
  border = NULL
)

Arguments

mapping, data

Standard layer overrides.

color

Fill colour when color is not mapped.

alpha

Fill opacity.

linewidth

Outline width in px; 0 (default) draws no outline.

border

Outline colour when linewidth > 0.

Value

A Layer to add with +.

Examples

d <- data.frame(x = c(1, 3, 2), y = c(1, 1, 3))
ggnext(d, aes(x, y)) + geom_polygon()
#> <ggnext plot>
#>   data:  3 x 2
#>   aes:   x = x, y = y
#>   layers: 1 
#>   coord: cartesian
#>   mode:  static