The R Project SVN R

Rev

Rev 25323 | Rev 42333 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 25323 Rev 26648
Line 5... Line 5...
5
  This function draws a polygon.  The final point will automatically
5
  This function draws a polygon.  The final point will automatically
6
  be connected to the initial point.
6
  be connected to the initial point.
7
}
7
}
8
\usage{
8
\usage{
9
grid.polygon(x=c(0, 0.5, 1, 0.5), y=c(0.5, 1, 0.5, 0),
9
grid.polygon(x=c(0, 0.5, 1, 0.5), y=c(0.5, 1, 0.5, 0),
-
 
10
             id=NULL, id.lengths=NULL,
10
             default.units="npc",
11
             default.units="npc",
11
             gp=gpar(), draw=TRUE, vp=NULL)
12
             gp=gpar(), draw=TRUE, vp=NULL)
12
}
13
}
13
\arguments{
14
\arguments{
14
  \item{x}{A numeric vector or unit object specifying x-locations.}
15
  \item{x}{A numeric vector or unit object specifying x-locations.}
15
  \item{y}{A numeric vector or unit object specifying y-locations.}
16
  \item{y}{A numeric vector or unit object specifying y-locations.}
-
 
17
  \item{id}{A numeric vector used to separate locations in \code{x} and
-
 
18
    \code{y} into multiple polygons.  All locations with the same
-
 
19
    \code{id} belong to the same polygon.}
-
 
20
  \item{id.lengths}{A numeric vector used to separate locations in \code{x} and
-
 
21
    \code{y} into multiple polygons.  Specifies consecutive blocks of
-
 
22
    locations which make up separate polygons.}
16
  \item{default.units}{A string indicating the default units to use
23
  \item{default.units}{A string indicating the default units to use
17
    if \code{x}, \code{y}, \code{width}, or \code{height}
24
    if \code{x}, \code{y}, \code{width}, or \code{height}
18
    are only given as numeric vectors.}  
25
    are only given as numeric vectors.}  
19
  \item{gp}{An object of class \code{gpar}, typically the output
26
  \item{gp}{An object of class \code{gpar}, typically the output
20
    from a call to the function \code{gpar}.  This is basically
27
    from a call to the function \code{gpar}.  This is basically
Line 32... Line 39...
32
\author{Paul Murrell}
39
\author{Paul Murrell}
33
\seealso{
40
\seealso{
34
  \link{Grid},
41
  \link{Grid},
35
  \code{\link{viewport}}
42
  \code{\link{viewport}}
36
}
43
}
-
 
44
\examples{
-
 
45
grid.polygon()
-
 
46
# Using id (NOTE: locations are not in consecutive blocks)
-
 
47
grid.newpage()
-
 
48
grid.polygon(x=c((0:4)/10, rep(.5, 5), (10:6)/10, rep(.5, 5)),
-
 
49
             y=c(rep(.5, 5), (10:6/10), rep(.5, 5), (0:4)/10),
-
 
50
             id=rep(1:5, 4),
-
 
51
             gp=gpar(fill=1:5))
-
 
52
# Using id.lengths
-
 
53
grid.newpage()
-
 
54
grid.polygon(x=outer(c(0, .5, 1, .5), 5:1/5),
-
 
55
             y=outer(c(.5, 1, .5, 0), 5:1/5),
-
 
56
             id.lengths=rep(4, 5),
-
 
57
             gp=gpar(fill=1:5))
-
 
58
}
37
\keyword{dplot}
59
\keyword{dplot}