Draws an axis-aligned rectangle per row from explicit corners. Use it for highlight bands, annotation boxes, and any hand-placed block; for a regular grid shaded by value use geom_tile().

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

Arguments

mapping, data

Standard layer overrides. Requires xmin, xmax, ymin and ymax.

color

Fill colour when color is not mapped.

alpha

Fill opacity.

linewidth

Border width in px; 0 (default) draws no border.

border

Border colour when linewidth > 0.

Value

A Layer to add with +.

Examples

d <- data.frame(x1 = c(1, 3), x2 = c(2, 5), y1 = c(1, 2), y2 = c(4, 3))
ggnext(d, aes(xmin = x1, xmax = x2, ymin = y1, ymax = y2)) + geom_rect()
#> <ggnext plot>
#>   data:  2 x 4
#>   aes:   xmin = x1, xmax = x2, ymin = y1, ymax = y2
#>   layers: 1 
#>   coord: cartesian
#>   mode:  static