\Header{rect}{Draw a Rectangle}
\keyword{aplot}{rect}
\begin{Usage}
\begin{verbatim}
rect(xleft, ybottom, xright, ytop,
     col=NULL, border=par("fg"), lty=NULL, xpd=FALSE)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\texttt{xleft}] a vector (or scalar) of left x positions.
\item[\texttt{ybottom}] a vector (or scalar) of bottom y positions.
\item[\texttt{xright}] a vector (or scalar) of right x positions.
\item[\texttt{ytop}] a vector (or scalar) of top y positions.
\item[\texttt{col}] color(s) to fill the rectangle(s) with.
\item[\texttt{border}] color for rectangle border(s).
\item[\texttt{lty}] line type for borders; defaults to \texttt{"solid"}.
\item[\texttt{xpd}] logical (\emph{``expand''}); if \texttt{FLASE}, everything is
clipped to the plot region.
\end{ldescription}
\end{Arguments}
\begin{Description}
\texttt{rect} draws a rectangle (or sequence of rectangles) with the
given coordinates.  It is a primitive function used in
\texttt{\Link{hist}}.  The value supplied, i.e., \texttt{xleft, ...},
are relative to the current plotting region. If the x-axis goes from
100 to 200 then \texttt{xleft} must be larger than 100 and \texttt{xright}
must be less than 200.\end{Description}
\begin{SeeAlso}
\texttt{\Link{box}} for the ``standard'' box around the plot;
\texttt{\Link{polygon}} and \texttt{\Link{segments}} for flexible line
drawing.\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
## 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))
\end{ExampleCode}
\end{Examples}

