plotting spline interpolated lines
SplinePlot is used to create smooth line plots of arbitrary data in up to three dimensions on the basis of spline interpolation. Basically, SplinePlot is very similar to LinePlot, however, automatically generates a smooth line based on spline interpolated intermediate points as shown in the example below.
Simply create a new SplinePlot object and provide its constructor with a positions array containing the data you wish to visualize. SplinePlot acts just like any other plot object in ILNumerics Visualization Engine. It is commonly used inside a plot cube object.
If you want to plot data with two or more dimensions, you may split the data into a corresponding number of one dimensional arrays. However, it is still important that the number of elements of each array is the same. The code below displays the constructor overloads of SplinePlot.
Example: Constructor overloads.
Once your plot object exists, you can use the Update() method for further configuration.
The following plot was created by providing SplinePlot with a one dimensional positions array. Later, its Update() method is called to reduce the number of elements in the positions array. As a result the smooth curve only goes through the first six vertices.
Example: A spline interpolated plot of one-dimensional data.
While providing the constructor with a positions array is mandatory, specifying further parameters such as the color, style and width of the line is optional. Feel free to add markers to further customize your plot. Furthermore, you may determine a tag, in order to facilitate finding your plot object within your complex scene graph later or modify the resolution, a factor for the production of new query points.
If the property resolution is set to 1, sample points are connected via straight lines. A value greater than 1 defines the number of new query points that are automatically generated between the original sample points. The resolution can be modified at any time during the lifetime of an SplinePlot object. By default the resolution is set to 3. It is not recommended to set the value below 3 to avoid artefacts during rendering.
Example: Comparison of two spline plots based on two-dimensional data with different resolution
Another optional parameter that is worth mentioning here is useSplinePathFor1D, which defines the calulation method for 1D data sets. By default it is set to true , hence the splinepath() method is used. This creates a spline by sampling from a parameterized path and connecting all the points specified. If useSplinePathFor1D is set to false, the spline() method will be used instead: A not-a-knot spline with regular interval subsampling.
Example: Comparison of two spline plots with different useSplinePathFor1D values
If you do not want to specify a resolution, you may set the resolution to null. Subsequently, a resolution will be calculated for you based on the data you have entered and the current view. It doesn’t matter if you choose to minimize or enlarge your spline plot. Since the resolution will be adjusted automatically, it will always be smooth.
Note that the auto resolution function is not available for three dimensional data. Moreover, if the data is one dimensional the property useSplinePath will be set to true.
The example below displays two spline plots based on the same data set. The black one has a resolution of 8, while the resolution of the red one is calculated automatically. The spline plot with the specified resolution needs to be adjusted to make it smooth. Finding the correct resolution, does not seem too complicated at first glance. Initially, you might tend to set the resolution to a very high value. But what if you are looking at a very large data set? This can really slow down the rendering process. So, let’s imagine you choose a moderate resolution, but what happens if you decide to enlarge a selected part of your spline plot? Correct, you will probably have to adjust the resolution again. Using auto resolution you don’t have to worry about this. The optimal resolution will be calculated automatically, enabling enlarging and minimizing while maintaining a smooth curve.
Removal of NAn values
Since data containing NaN values cannot be interpolated, the NaN values are now automatically removed. Only if you have entered one dimensional data, the NaN values will be substituted with values resulting from an interpolation.
Further information and limitations
SplinePlot interpolates each dimension of the positions array seperately. To make clear what that means, we created a smooth line of a two dimensional data set using SplinePlot. Here, the X and Y arrays are both spline interpolated, resulting in the salmon colored line. In contrast, the blue line results from only spline interpolating the Y array, using a method of the more extensive interpolation toolbox.Example: Comparison of SplinePlot and the method Interpolation.spline()
One limitation is that the provided positions array must comprise at least four elements per dimension, since at least four vertices are required for the underlying spline interpolation. Furthermore, note that SplinePlot can not handle NaN values. In order to replace all NaN values, you could use the interpolation toolbox methods. The result can then be provided to the spline plot object for rendering.
Since SplinePlot derives from Group, you have access to all configuration options of common group objects.
Example: A spline interpolated plot of three-dimensional data.
For more information check out: