grid.polyclip | R Documentation |
These functions allow two or more grobs to be combined using one of the following operations: intersection, union, minus, and xor.
polyclipGrob(A, B, op="intersection",
openFn=xyListToLine, closedFn=xyListToPath,
name=NULL, gp=gpar(), ...)
grid.polyclip(A, B, ...)
A |
A grob, gList, or gTree, or a gPath or a character value identifying a grob that has already been drawn. This is known as the subject grob. |
B |
A grob, gList, or gTree, or a gPath or a character value identifying a grob that has already been drawn. This is known as the clip grob. |
op |
A character value describing the operation. One of
|
openFn |
The function used to create grobs from the open shapes in the result. |
closedFn |
The function used to create grobs from the closed shapes in the result. |
name |
A name for the resulting grob. |
gp |
Graphical parameter settings for the resulting grob. |
... |
For |
The subject grob is combined with the clip grob using the op
operation.
The grobs are converted to coordinates by calling grid::grobCoords
and then the operation is performed by calling polyclip
.
The result is a new grob. In the case of grid.polyclip
,
this new grob will be drawn on the current device. In the special
case that A
is a gPath, by default, the new grob will
replace the old grob (the original grob identified by A
)
in the current scene
(and the new grob will use the same gp
settings as the
old grob).
The subject grob can be any combination of open or closed shapes (e.g., a combination of lines and polygons), but the clip grob must only consist of closed shapes.
polyclipGrob
returns a gTree with two children, one
representing the open shapes within the result and one representing the
closed shapes within the result.
grid.polyclip
is only used for its side-effect of drawing
on the current graphics device.
Paul Murrell
polyclip
r <- rectGrob(x=1/3, y=1/3, width=.4, height=.4)
c <- circleGrob(x=2/3, y=2/3, r=.2)
grid.draw(r)
grid.draw(c)
grid.polyclip(r, c, gp=gpar(fill="grey"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.