
Last chance! 50% off unlimited learning
Sale ends in
grid.clip(...)
clipGrob(x = unit(0.5, "npc"), y = unit(0.5, "npc"),
width = unit(1, "npc"), height = unit(1, "npc"),
just = "centre", hjust = NULL, vjust = NULL,
default.units = "npc", name = NULL, vp = NULL)
"left"
,
"right"
, "centre"
, "center"
, "bottom"
,
and "top"
. For numeric values, 0 means left alignment
and 1 means right alignment.
just
setting.just
setting.x
, y
, width
, or height
are only given as numeric vectors.clipGrob
.clipGrob
returns a clip grob.grid.clip
enforces the clipping. Pushing or popping a viewport always overrides the clip
region set by a clip grob, regardless of whether that viewport
explicitly enforces a clipping region.viewport
# draw across entire viewport, but clipped
grid.clip(x = 0.3, width = 0.1)
grid.lines(gp=gpar(col="green", lwd=5))
# draw across entire viewport, but clipped (in different place)
grid.clip(x = 0.7, width = 0.1)
grid.lines(gp=gpar(col="red", lwd=5))
# Viewport sets new clip region
pushViewport(viewport(width=0.5, height=0.5, clip=TRUE))
grid.lines(gp=gpar(col="grey", lwd=3))
# Return to original viewport; get
# clip region from previous grid.clip()
# (NOT from previous viewport clip region)
popViewport()
grid.lines(gp=gpar(col="black"))
Run the code above in your browser using DataLab