Example: ErrorBar Chart

An ErrorBar chart is constructed in this example. Three data sets are used and a legend is added to the chart.
using Imsl.Chart2D;
using System;
using System.Windows.Forms;

public class ErrorBarEx1 : FrameChart 
{
    public ErrorBarEx1() 
    {
        Chart chart = this.Chart;
        AxisXY axis = new AxisXY(chart);

        int    npoints = 20;
        double dx = .5 * Math.PI/(npoints - 1);
        double[] x = new double[npoints];
        double[] y1 = new double[npoints];
        double[] y2 = new double[npoints];
        double[] y3 = new double[npoints];
        double[] low1 = new double[npoints];
        double[] low2 = new double[npoints];
        double[] low3 = new double[npoints];
        double[] hi1 = new double[npoints];
        double[] hi2 = new double[npoints];
        double[] hi3 = new double[npoints];

        //    Generate some data
        for (int i = 0; i < npoints; i++)
        {
            x[i] = i * dx;
            y1[i] = System.Math.Sin(x[i]);
            low1[i] = x[i] - .05;
            hi1[i] = x[i] + .05;
            y2[i] = System.Math.Cos(x[i]);
            low2[i] = y2[i] - .07;
            hi2[i] = y2[i] + .03;
            y3[i] = System.Math.Atan(x[i]);
            low3[i] = y3[i] - .01;
            hi3[i] = y3[i] + .04;
        }
        
        // Data
        Data d1 = new Data(axis, x, y1);
        Data d2 = new Data(axis, x, y2);
        Data d3 = new Data(axis, x, y3);
        
        //    Set Data Type to Marker
        d1.DataType = Data.DATA_TYPE_MARKER;
        d2.DataType = Data.DATA_TYPE_MARKER;        
        d3.DataType = Data.DATA_TYPE_MARKER;

        //    Set Marker Types
        d1.MarkerType = Data.MARKER_TYPE_CIRCLE_PLUS;
        d2.MarkerType = Data.MARKER_TYPE_HOLLOW_SQUARE;
        d3.MarkerType = Data.MARKER_TYPE_ASTERISK;

        //    Set Marker Colors
        d1.MarkerColor = System.Drawing.Color.Red;
        d2.MarkerColor = System.Drawing.Color.Black;
        d3.MarkerColor = System.Drawing.Color.Blue;

        //    Create an instances of ErrorBars
        ErrorBar ebar1 = new ErrorBar(axis, x, y1, low1, hi1);
        ErrorBar ebar2 = new ErrorBar(axis, x, y2, low2, hi2);
        ErrorBar ebar3 = new ErrorBar(axis, x, y3, low3, hi3);
        
        //    Set Data Type to Error_X
        ebar1.DataType = ErrorBar.DATA_TYPE_ERROR_X;
        ebar2.DataType = ErrorBar.DATA_TYPE_ERROR_Y;
        ebar3.DataType = ErrorBar.DATA_TYPE_ERROR_Y;
        
        //    Set Marker Colors
        ebar1.MarkerColor = System.Drawing.Color.Red;
        ebar2.MarkerColor = System.Drawing.Color.Black;
        ebar3.MarkerColor = System.Drawing.Color.Blue;
        
        //    Set Data Labels
        d1.SetTitle("Sine");
        d2.SetTitle("Cosine");
        d3.SetTitle("ArcTangent");
        
        //    Add a Legend
        Legend legend = chart.Legend;
        legend.SetTitle(new Text("Legend"));
        legend.IsVisible = true;
        
        //    Set the Chart Title
        chart.ChartTitle.SetTitle("Error Bar Plot");
    }

    public static void Main(string[] argv) 
    {
        System.Windows.Forms.Application.Run(new ErrorBarEx1());
    }
}

Output

Link to C# source.