2.2.4.17.1 GraphLayer::AddErrBar

Contents

Description

Adds an error bar plot to an existing dataplot from Column object.


Adds an error bar plot to an existing dataplot from Dataset object.

Syntax

int AddErrBar( Curve & cData, Column & colErrBar )


int AddErrBar( Curve & cData, Dataset & dsErrBar )

Parameters

cData
[input] Data curve to add the error bar to
colErrBar
[input] the Data curve to be used as error bar


cData
[input] Data curve to add the error bar to
dsErrBar
[input] the dataset to be used as errorbar

Return

the index of the added error bar dataplot in layer, or -1 if failed.


the index of the added error bar dataplot in layer, or -1 if failed.

Examples

EX1

// For this example to run, a worksheet with columns "A" and "B" and another column
// (the third column) must exist with some numeric data in them. 
// After the function executes, the third column of the worksheet will be used
// for error bars.
void    GraphLayer_AddErrBar_ex1()
{
    Worksheet wks = Project.WorksheetPages(0).Layers(0);
    if(wks)
    {
        // a dataplot in the layer that uses column B as Y and column A as X            
        Curve        cc(wks, 0, 1);
                
        GraphPage        gp;
        gp.Create();
        GraphLayer    lay = gp.Layers();
        
        // add Y plotting
        int            nPlotIndex = lay.AddPlot(cc, IDM_PLOT_SCATTER);
        out_int("nPlotIndex = ", nPlotIndex);
        
        // use the third column in the worksheet for error bar:
        Column    colErrBar(wks, 2);                    
        
        // plot error bar attach to Y in cc
        int            nErrPlotIndex = lay.AddErrBar(cc, colErrBar);
        out_int("nErrPlotIndex = ", nErrPlotIndex);
        
        lay.Rescale();
        legend_update(lay);
        lay.GetPage().Refresh();
    }
}


EX2

//This example adds an error bar plot to an existing dataplot. 
//For this example to run, a worksheet with columns "A" and "B" and "C" must exist 
//with some numeric data in them. 
void GraphLayer_AddErrBar_ex2()
{
    Worksheet wks = Project.WorksheetPages(0).Layers(0);
    GraphPage gp;
    gp.Create("origin");    
    GraphLayer glMyLayer = gp.Layers(0);
    if(wks && glMyLayer)
    {
        Curve crvMyCurve(wks, 0, 1);
        glMyLayer.AddPlot(crvMyCurve);
        Dataset dsErrBar(wks, 2);
        int iPlotIndex = glMyLayer.AddErrBar(crvMyCurve, dsErrBar);
        if (iPlotIndex==-1)
            printf("ErrBar Plotting Error!");
        else
            printf("Errbar added successfully!");
        glMyLayer.Rescale();
    }
}

Remark

See Also

Header to Include

origin.h