X and Y datasets in Origin are generally expressed in columns, not rows. Here is some bare bones code that will make a plot using an X and Y datasets that are in columns on different sheets.
void wp1(){
DataRange dr;
dr.Add("X", "[Book1]Sheet1!A:A");
dr.Add("Y", "[Book1]Sheet2!C:C");
GraphPage gP;
GraphLayer gL;
gP.Create();
gL=gP.Layers(0);
gL.AddPlot(dr, IDM_PLOT_SCATTER);
gL.Rescale();
gP.SetShow();
}
If you realy have to have your data in rows for some reason, here is somewhat clunkier code that will take exactly the ranges you described, transpose them to a new sheet, and then plot. I'm not sure if there is a way to plot directly from rows onto a scatter plot in the way you describe.
void wp2(){
DataRange dr;
dr.Add("X", "[Book1]Sheet1![1]:[1]");
dr.Add("Y", "[Book1]Sheet2![3]:[3]");
vector vX, vY;
dr.GetData(vX,0);
dr.GetData(vY,1);
Worksheet wksTranspose;
wksTranspose.Create();
Dataset dsX=wksTranspose.Columns(0);
Dataset dsY=wksTranspose.Columns(1);
dsX=vX;
dsY=vY;
Curve cc(wksTranspose,1);
GraphPage gP;
GraphLayer gL;
gP.Create();
gL=gP.Layers(0);
gL.AddPlot(cc, IDM_PLOT_SCATTER);
gL.Rescale();
gP.SetShow();
}
Both these functions are O8 specific.
Edited by - cjfraz on 02/03/2008 11:25:31 AM