Description Usage Arguments Details Value Author(s) See Also Examples
These functions create and draw a polygon. The final point will automatically be connected to the initial point.
1 2 3 4 5 6 7 8 |
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 |
id.lengths |
A numeric vector used to separate locations in |
default.units |
A string indicating the default units to use
if |
name |
A character identifier. |
gp |
An object of class |
draw |
A logical value indicating whether graphics output should be produced. |
vp |
A Grid viewport object (or NULL). |
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
).
A grob object.
Paul Murrell
Grid,
viewport
1 2 3 4 5 6 7 8 9 10 11 12 13 | 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))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.