Name

spline

spline type x y sx sy

Compute a spline fitted to a set of data points. The Type argument is either natural or quadratic.

Parameters x and y are vectors representing points of data to be fitted to the spline. Values of x must be monotonically increasing.

Parameter sx is a vector containing the x-coordinates of the new points to be interpolated by the spline function. These must also be monotonically increasing and lie between the first and last values of x.

The spline command creates a new vector sy, which contains the y-coordinates corresponding to the x-coordinate values stored in sx calculated using the spline function.

Example

vector x y sx sy
xset {0.1 1.5 3.4 5.6}
y set {0.2 4.5 1.3 9.8}
xpopulate sx 10
spline natural x y sx sy
graph .graph
.graph element create original -x x -y y -color blue
.graph element create spline -x sx -y sy -color red
table . .graph

Get Tcl/Tk in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.