The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 plot data from different sheets ?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

pierremx

Belgium
Posts

Posted - 01/30/2008 :  12:36:05 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hello,

How can I plot graph with data from different sheets ?

Ie :
X col = [Book1]Sheet1 row 1
Y col = [Book1]Sheet2 row 3

Is it possible ?

Regards,
Pierre.

cjfraz

USA
22 Posts

Posted - 02/03/2008 :  10:39:52 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000