bSpline: Plot piecewise B-splines

Description Usage Arguments Value Author(s) See Also Examples

Description

Add piecewise B-splines of supplied order to a plot. The function uses the lines function to plot to the current device.

Usage

1
bSpline(x, y, order = 4, n.evals = 100)

Arguments

x

A vector giving the x-coordinates of the control points. Alternatively, x can be a list or data.frame where the two first elements (or columns) are used as x and y.

y

An optional vector giving the y-coordinates of the control points.

order

the order of the B-splines. Default is cubic (order = 4).

n.evals

integer giving the number of points the spline should be evaluated at. Default is 100.

Value

Returns a list of length 2 with entries x and y of x and y coordinates corresponding to the evaluations of the B-spline.

Author(s)

Anders Ellern Bilgrau

See Also

See also lines and bezier.

Examples

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")

AEBilgrau/Bmisc documentation built on May 5, 2019, 11:28 a.m.