Industrial Data Science
in C# and .NET:
Simple. Fast. Reliable.

ILNumerics - Technical Computing

Modern High Performance Tools for Technical

Computing and Visualization in Industry and Science

tgt

# Spline Interpolated Line Plots

SplinePlot is available for the visualization of data in 1, 2, and 3 dimensions. Basically, spline plots act like LinePlot but generates a smooth line with spline interpolated intermediate points automatically.

Example: Plot a smooth line using SplinePlot based on 20 sample points.

SplinePlot supports the same properties and parameters like LinePlot, including markers and all line properties. That way it is easy to exchange one for the other in your code. Note that in the example above, the markers were configured for the spline line.

## Data Formats

Three constructors are defined for SplinePlot. Likewise for LinePlot, SplinePlot constructors accept matrices of size [n x 3], with data sets X,Y,Z as rows. Alternatively, individual column or row vectors can be provided as X, Y and (optionally) Z data.

Please note, that for not-a-knot spline interpolation at least 4 points are required. Use LinePlot to visualize scalars or datasets with less than 4 points defined.

## 1D Splines: Spline Method Definition

By using SplinePlot constructor with data set defined as vector row or column, additional parameter could be set. Boolean parameter useSplinePathFor1D defines the spline calculation method for 1D data set. By default it is set to true, that means that, spline will be calculated using splinepath() method, i.e. the spline line will be created by subsampling from a parameterized path connecting all points specified. If useSplinePathFor1D is set to false, the spline will be calculated using the spline() method: a not-a-knot spline with regular interval subsampling. The following example demonstrates the difference between both methods.

Example: compare two similar spline lines with individual useSplinePathFor1D parameters.

## Resolution Property

SplinePlot allows also to set a spline resolution property. If resolution is set to 1, sample points are connected with straight lines. Setting resolution more than 1, defines the number of new query points on intervals between original given sample points, with the interpolated values being calculated automaticaly.

The resolution property can be changed at any time during the lifetime of SplinePlot. By default, resolution is set to 3. It is recommended to set the resolution parameter to a value no lower than 3 to prevent from artefacts during rendering.

The following 2D example shows how the resolution parameter works. You may change the resolution value to see the difference:

## Handling NaN Values

SplinePlot is not able to handle NaN values. One may use the Interpolation toolbox methods in order to replace all NaN values in the data first and provide the result to the spline plot object for rendering.