rect                  package:base                  R Documentation

_D_r_a_w _a _R_e_c_t_a_n_g_l_e

_D_e_s_c_r_i_p_t_i_o_n:

     `rect' draws a rectangle (or sequence of rectangles) with the
     given coordinates.  It is a primitive function used in `hist'.

_U_s_a_g_e:

     rect(xleft, ybottom, xright, ytop,
          col=NULL, border=par("fg"), lty=NULL, lwd=par("lwd"), xpd=FALSE)

_A_r_g_u_m_e_n_t_s:

   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.

     col: color(s) to fill the rectangle(s) with.

  border: color for rectangle border(s).

     lty: line type for borders; defaults to `"solid"'.

     lwd: width for borders.

     xpd: logical (``expand''); if `FALSE', everything is clipped to
          the plot region.

_D_e_t_a_i_l_s:

     The positions 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.

_S_e_e _A_l_s_o:

     `box' for the ``standard'' box around the plot; `polygon' and
     `segments' for flexible line drawing.

_E_x_a_m_p_l_e_s:

     ## set up the plot region:
     plot(c(100, 250), c(300, 450), type = "n",
          main = "2 x 11 rectangles; `rect(100+i,300+i,  150+i,380+i)'")
     i <- 4*(0:10)
     ## draw rectangles with bottom left (100, 300)+i  and top right (150, 380)+i
     rect(100+i, 300+i, 150+i, 380+i, col=rainbow(11, start=.7,end=.1))
     rect(240-i, 320+i, 250-i, 410+i, col=heat.colors(11), lwd=i/5)

