Line Plots in .NET (C# and Visual Basic)
Line plots are used to visualize data in 1, 2 or 3 dimensions. Data points are connected by straight lines. Learn more about Line Plots in .NET (C# and Visual Basic):
We created some random data vector and provide it to a new ILLinePlot object. The Line Plot is than added to the plotting cube: Since we did only provide 1-dimensional data to the plot cube, the values are interpreted as Y values and the X values are automatically created.
X-Y plots are generated by simply providing a matrix with two rows: X values in the first row, Y values in the second row:
The scheme applies similarly to 3D Line Plots, which expects 3 rows for X, Y and Z-coordinates.
Handling NaN Values
Line Plots are able to handle NaN values. Those points, which have a coordinate component of NaN (Not a Number) are simply omited from rendering. One may utilize this property for non-continous lines and to realize several lines by using a single ILLinePlot object.
Auto-Coloring Line Plots
If no color was specified in the constructor, the color for each line is set automatically. Every subsequent new Line Plot receives an individual color.
In the next example, 64 Line Plots are created. The Line Plots get automatically colored by the keyframes in the Lines colormap, which is displayed eventually in the result:
Line Plots: Customizing Line Properties
Line Plots expose the ILLinePlot.Line property. Lines are made out of line strips (ILLineStrip) and provide the following options for configuration:
The next example creates a whole bunch of Line Plots, all with different style combinations. We use a more efficient method than creating every line plot separately. ILLinePlot provides the static method ILLinePlot.CreateXPlots() for creating a number of regular Line Plots from the rows of a matrix. It allows the definition of style parameter collections for color, style and width of every line:
If any property of the line needs to get changed after creation, the ILLinePlot.Line property provides access to the line strip object for full configuration. If the need arises, the configuration may even include the modification of any vertex buffer of the line strip object. That way fully dynamic plots can be realized.
Line Plots allow the definition of markers for their data points. Markers can be configured either in the contructor of ILLinePlot …
Or, alternatively, the ILLinePlot.Marker property allows the (re-)configuration of markers:
All existing predefined marker shapes are displayed by the following code:
Markers can be arbitrarily customized. They allow the addition of custom shapes. ILLinePlot.Marker is a group node, which serves as a template for all markers to be drawn. All shapes added to the ILLinePlot.Marker group will be repeatedly displayed for every data point.
In the next example, the marker from the example above will be extended by a crosshair, which is made of two simple red lines, added to the marker node:
Coordinate System for Markers
A marker is a group node, which defines its own coordinate system. The node transforms vertex positions of its child shapes from the XY range [-1…1] to the pixel size defined by ILLinePlot.Marker.Size. If the Size property is set to 9 (default) this means, objects which range from -1 to 1 in X or Y will have a length of 9 pixels in X or Y direction, centered at the position of the data point.
Markers are always oriented towards the camera. Even for 3D plots, with arbitrary rotation applied, the X-Y plane of a marker will always face the camera. The Z-coordinate of the vertices of marker shapes can be used to define the order of markers in Z-directions.