grid.curve(...)
curveGrob(x1, y1, x2, y2, default.units = "npc", curvature = 1, angle = 90, ncp = 1, shape = 0.5, square = TRUE, squareShape = 1, inflect = FALSE, arrow = NULL, open = TRUE, debug = FALSE, name = NULL, gp = gpar(), vp = NULL)
arcCurvature(theta)
x1
, y1
, x2
or y2
are only given as numeric values.grid.xspline
for more details.ncp
is 1 and angle
is 90,
this is typically TRUE
, otherwise this should probably
be set to FALSE
(see Examples below).shape
value to control the behaviour
of the curve relative to any additional control point that
is inserted if square
is TRUE
.arrow
function.gpar
, typically the output
from a call to the function gpar
. This is basically
a list of graphical parameter settings.curveGrob
.grid.curve
draws the curve. The arcCurvature
function can be used to calculate a
curvature
such that control points are generated on
an arc corresponding to angle theta
. This is typically
used in conjunction with a large ncp
to produce a curve
corresponding to the desired arc.
viewport
,
grid.xspline
,
arrow
curveTest <- function(i, j, ...) {
pushViewport(viewport(layout.pos.col=j, layout.pos.row=i))
do.call("grid.curve", c(list(x1=.25, y1=.25, x2=.75, y2=.75), list(...)))
grid.text(sub("list\\((.*)\\)", "\\1",
deparse(substitute(list(...)))),
y=unit(1, "npc"))
popViewport()
}
# grid.newpage()
pushViewport(plotViewport(c(0, 0, 1, 0),
layout=grid.layout(2, 1, heights=c(2, 1))))
pushViewport(viewport(layout.pos.row=1,
layout=grid.layout(3, 3, respect=TRUE)))
curveTest(1, 1)
curveTest(1, 2, inflect=TRUE)
curveTest(1, 3, angle=135)
curveTest(2, 1, arrow=arrow())
curveTest(2, 2, ncp=8)
curveTest(2, 3, shape=0)
curveTest(3, 1, curvature=-1)
curveTest(3, 2, square=FALSE)
curveTest(3, 3, debug=TRUE)
popViewport()
pushViewport(viewport(layout.pos.row=2,
layout=grid.layout(3, 3)))
curveTest(1, 1)
curveTest(1, 2, inflect=TRUE)
curveTest(1, 3, angle=135)
curveTest(2, 1, arrow=arrow())
curveTest(2, 2, ncp=8)
curveTest(2, 3, shape=0)
curveTest(3, 1, curvature=-1)
curveTest(3, 2, square=FALSE)
curveTest(3, 3, debug=TRUE)
popViewport(2)
Run the code above in your browser using DataLab