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
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 plot data from different sheets ?

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
pierremx Posted - 01/30/2008 : 12:36:05 PM
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.
1   L A T E S T    R E P L I E S    (Newest First)
cjfraz Posted - 02/03/2008 : 10:39:52 AM
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

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000