This help topic is for R version 0.60. For the current version of R, try https://stat.ethz.ch/R-manual/R-patched/library/base/html/rect.html
rect {base}R Documentation

Draw a Rectangle

Description

rect draws a rectangle (or sequence of rectangles) with the given coordinates. It is a primitive function used in hist. The value supplied, i.e., xleft, ..., are relative to the current plotting region. If the x-axis goes from 100 to 200 then xleft must be larger than 100 and xright must be less than 200.

Usage

rect(xleft, ybottom, xright, ytop, ...)

Arguments

xleft

a vector (or scalar) of left x positions.

ybottom

a vector (or scalar) of bottom y positions.

xright

a vector (or scalar) of right x positions.

ytop

a vector (or scalar) of top y positions.

...

Further graphical parameters (see par) may also be supplied as arguments.

See Also

box for the “standard” box around the plot; polygon and segments for flexible line drawing.

Examples

## set up the plot region:
plot(c(100, 250), c(300, 450), type = "n",
     main = "11 rectangles using `rect(120+i,300+i,  177+i,380+i)'")
i <- 4*(0:10)
## draw rectangles with bottom left (120, 300)+i  and top right (177, 380)+i
rect(120+i, 300+i, 177+i, 380+i, col=rainbow(11, start=.7,end=.1))

[Package base version 0.60 ]