grid.polygon              package:grid              R Documentation

_D_r_a_w _a _P_o_l_y_g_o_n

_D_e_s_c_r_i_p_t_i_o_n:

     These functions create and draw a polygon. The final point will
     automatically be connected to the initial point.

_U_s_a_g_e:

     grid.polygon(x=c(0, 0.5, 1, 0.5), y=c(0.5, 1, 0.5, 0),
                  id=NULL, id.lengths=NULL,
                  default.units="npc", name=NULL,
                  gp=gpar(), draw=TRUE, vp=NULL)
     polygonGrob(x=c(0, 0.5, 1, 0.5), y=c(0.5, 1, 0.5, 0),
                  id=NULL, id.lengths=NULL,
                  default.units="npc", name=NULL,
                  gp=gpar(), vp=NULL)

_A_r_g_u_m_e_n_t_s:

       x: A numeric vector or unit object specifying x-locations.

       y: A numeric vector or unit object specifying y-locations.

      id: A numeric vector used to separate locations in 'x' and 'y'
          into multiple polygons.  All locations with the same 'id'
          belong to the same polygon.

id.lengths: A numeric vector used to separate locations in 'x' and 'y'
          into multiple polygons.  Specifies consecutive blocks of
          locations which make up separate polygons.

default.units: A string indicating the default units to use if 'x',
          'y', 'width', or 'height' are only given as numeric vectors.

    name: A character identifier. 

      gp: An object of class 'gpar', typically the output from a call
          to the function 'gpar'.  This is basically a list of
          graphical parameter settings.

    draw: A logical value indicating whether graphics output should be
          produced.

      vp: A Grid viewport object (or NULL).

_D_e_t_a_i_l_s:

     Both functions create a polygon grob (a graphical object
     describing a polygon), but only 'grid.polygon' draws the polygon
     (and then only if 'draw' is 'TRUE').

_V_a_l_u_e:

     A grob object.

_A_u_t_h_o_r(_s):

     Paul Murrell

_S_e_e _A_l_s_o:

     Grid, 'viewport'

_E_x_a_m_p_l_e_s:

     grid.polygon()
     # Using id (NOTE: locations are not in consecutive blocks)
     grid.newpage()
     grid.polygon(x=c((0:4)/10, rep(.5, 5), (10:6)/10, rep(.5, 5)),
                  y=c(rep(.5, 5), (10:6/10), rep(.5, 5), (0:4)/10),
                  id=rep(1:5, 4),
                  gp=gpar(fill=1:5))
     # Using id.lengths
     grid.newpage()
     grid.polygon(x=outer(c(0, .5, 1, .5), 5:1/5),
                  y=outer(c(.5, 1, .5, 0), 5:1/5),
                  id.lengths=rep(4, 5),
                  gp=gpar(fill=1:5))

