Description Usage Arguments Value Author(s) See Also Examples
Add piecewise B-splines of supplied order to a plot. The function
uses the lines
function to plot to the current device.
1 |
x |
A vector giving the x-coordinates of the control points.
Alternatively, |
y |
An optional vector giving the y-coordinates of the control points. |
order |
the order of the B-splines. Default is cubic ( |
n.evals |
integer giving the number of points the spline should be evaluated at. Default is 100. |
Returns a list
of length 2 with entries x
and y
of
x and y coordinates corresponding to the evaluations of the B-spline.
Anders Ellern Bilgrau
1 2 3 4 5 6 7 8 | n <- 20
x <- list(x = cumsum(rnorm(2*n)), y = cumsum(rnorm(2*n)))
plot(x, pch = 16, col = "grey")
i <- seq_along(x[[1]] - 1)
with(x, arrows(x[i], y[i], x[i+1], y[i+1], col = "grey"))
lines(bSpline(x, order = 4), col = "red")
lines(bSpline(x, order = 5), col = "blue")
lines(bSpline(x, order = 6), col = "green")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.