Markers for 2D line graphs

Every datapoint for 2D line graphs may get emphasized by a marker. This helps to distinguish them among other graphs. Markers can be configured independently from the line of each ILPlot2DGraph object. 3 representations are possible for markers:

  • predefined shapes (triangle, diamond, circle etc.)
  • partial TEX expressions
  • user defined bitmaps

In the following picture examples of all 3 marker types are shown. Read the details below.

Properties for markers

The following properties are common to all markers:

Marker Property Description
Color Color for markers
Shape Specify shape and type of marker (see below)
Size Size of Markers in pixels. This may slightly differ for some marker shapes. [default: 10]
Visible true: markers will be visible, false: markers will not be shown [default]

The ILMarker.Shape property deserves special attention. It is used to determine the type (and shape) of underlying marker implementation. By assigning individual objects to that property, one configures the markers for rendering. The next table lists all 3 possibilites:

assigning ... to
ILMarker.Shape
... creates that marker type Description
MarkerStyles enum member ILStyledMarkerShape The enumeration provides several common marker shapes, like TriangleUp,Diamond,Circle,Dot etc.
string expression:
f.ex.:"\Omega_{\index}"
ILTexMarkerShape Every marker will be rendered as the result of interpretation of the string expression. The expression may contain simple alphanumeric values or all valid TEX expresions valid for ILAxis.Labels also. In addition to that, the following special sequences are valid too:
  • \index: will be replaced by the index of the datapoint at runtime
  • \xvalue: will be replaced by x value of the datapoint at runtime
  • \yvalue: will be replaced by y value at runtime
Bitmap ILBitmapMarkerShape User defined bitmap. The content of the bitmap will be used to define alpha blending on the markers rendering area.

Performance considerations

The mose performant way to render markers is archieved by using predefined marker styles. Especially the MarkerStyle.Dot and MarkerStyle.Square are best suited to be drawn very fast.

The most expensive types are partial TEX expressions. They must get evaluated on every single marker at runtime. In order to prevent for performance bottlenecks, the number of markers drawn that way is limited. By default only 50 markers are shown, evenly distributed over all datapoints. The limit can be configured, by accessing the underlying marker type.

Advanced configuration for marker types

By assigning individual objects to the ILMarker.Shape property, the shape turns into individual class instances. Those instances provide additional properties. They may be used to further configure the markers. Example:

//set the maximum limits of drawn points for texmarker shapes
(graph.Marker.Shape as ILTexMarkerShape).MaxLabelsDrawn = 30;
// set the format expression used to turn number into strings
(graph.Marker.Shape as ILTexMarkerShape).ValueFormat = "g3"; 
 

Marker example

The code used to create the plot shown on top of this page:

private void Form1_Load(object sender, EventArgs e) {
        m_panel = ILPanel.Create();
        m_panel.Dock = DockStyle.Fill;
        Controls.Add(m_panel);
        // Create sample data
        m_panel.Graphs.AddPlot2DGraph(ILSpecialData.sincos1D(61, 1.3) + ILMath.rand(61,2));
        // add horizontal line at 1
        m_panel.Graphs.AddPlot2DGraph(ILMath.linspace(2,44.0,8),ILMath.ones(1,8)); 
        // configure first graph's marker: prederfined MarkerStyle
        ILPlot2DGraph graph = (ILPlot2DGraph)m_panel.Graphs[0]; 
        graph.Marker.Shape = MarkerStyle.Diamond; 
        graph.Marker.Color = Color.LawnGreen; 
        graph.Marker.Size = 6; // small marker

        // configure 2nd graph's markers: tex expression
        graph = (ILPlot2DGraph)m_panel.Graphs[1];
        graph.Marker.Shape = "\\index"; 
        graph.Marker.Color = Color.DarkBlue; 
        graph.Marker.Size = 8; 
        // we only want 30 datapoints drawn that way: 
        (graph.Marker.Shape as ILTexMarkerShape).MaxLabelsDrawn = 30; 

        // configure 3rd graph's markers: bitmap
        graph = (ILPlot2DGraph)m_panel.Graphs[2];
        graph.Marker.Shape = Resource1.ILN20x25;
        graph.Marker.Color = Color.Red; 
        graph.Marker.Size = 14; 
        graph.Line.Visible = false; 
    }
}

Download the complete example project as VS2005 solution here.


Valid CSS! Valid XHTML 1.0 Transitional