2.2.4.17.2 GraphLayer::AddLabelPlotAddLabelPlot
Description
Adds a label plot to an existing dataplot.
Syntax
int AddLabelPlot( Curve & cData, Column & colLabel )
int AddLabelPlot( Curve & cData, Dataset & dsLabel )
Parameters
- cData
- [input] Data curve to add the label plot to
- colLabel
- [input] the Data curve to be used as label column
- cData
- [input] Data curve to add the label plot to
- dsLabel
- the dataset to be used as labels
Return
Examples
EX1
// For this example to run, a worksheet with columns "A" and "B" and another label column
// (the third column) must exist.
// After the function executes, the third column of the worksheet will be used
// for labels
void GraphLayer_AddLabelPlot_ex1()
{
//we need to first make sure the label column is really a Label column
Worksheet wks = Project.WorksheetPages(0).Layers(0);
if(wks)
{
if(!wks.Columns(2).SetType(OKDATAOBJ_DESIGNATION_L))
return;
}
else
return;
GraphPage gp;
gp.Create("origin");
GraphLayer lay = gp.Layers(0);
// a dataplot in the layer that uses column B as Y and column A as X
Curve cc(wks, 0, 1);
// first we plot col(B)
int nPlotIndex = lay.AddPlot(cc, IDM_PLOT_SCATTER);
// use the third column in the worksheet for labels:
Column colLabels(wks, 2);
nPlotIndex = lay.AddLabelPlot(cc, colLabels);
out_int("nPlotIndex = ", nPlotIndex);
lay.Rescale();
}
EX2
//For this example to run, a worksheet with columns "A"
//and "B" and a label column "C" must exist.
//Draw a 2d scatter plot with column C as lable.
void Graphlayer_AddLabelPlot_ex2()
{
Worksheet wks = Project.WorksheetPages(0).Layers(0);
if(wks)
{
if(!wks.Columns(2).SetType(OKDATAOBJ_DESIGNATION_L))
return;
Dataset dsLables(wks, 2);
GraphPage gp;
gp.Create("origin");
GraphLayer glMyLayer = gp.Layers(0);
Curve crvMyCurve(wks, 0, 1);
glMyLayer.AddPlot(crvMyCurve, IDM_PLOT_SCATTER);
int iPlotIndex = glMyLayer.AddLabelPlot(crvMyCurve, dsLables);
glMyLayer.Rescale();
if (iPlotIndex==-1)
printf("Lables adding Error!");
else
printf("Lables added successfully!");
}
else
return;
}
Remark
See Also
Header to Include
origin.h
|