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
 LabTalk Forum
 Plot different columns from different workbooks

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
alexapostu Posted - 07/05/2020 : 11:36:08 AM
I want to create a script that will plotxy 8 columns from different workbooks.
I have around 20 workbooks and each with 9 columns. I want to create graphs that wil plot the first column of each workbook and the second culumn, then the first column with the third and so on.

The below script will not help me because I do not know how to integrate a FOR in there.

win -t p temp.otp MyPlot; // create a graph window using template
doc -e W // loop all workbook in the project
{
string strName$ = layer.name$; // get the worksheet name
range rr = 1!col(2); // data range of column 2
string strPrefix$ = strName.Left(3)$; // get the prefix of worksheet name
string strSuffix$ = strName.Right(1)$; // get the suffix of worksheet name

int nActive = %(strSuffix$); // convert suffix to integer
if(strPrefix$ == "XYZ") // if prefix is XYZ, plot in the second row
nActive += 3;

win -a MyPlot; // activate the graph window
page.active = nActive; // activate the layer for plot
layer.include(rr); // plot in the active layer
layer -a; // rescale the layer
};
5   L A T E S T    R E P L I E S    (Newest First)
YimingChen Posted - 07/09/2020 : 2:03:26 PM
Please try the script below. Here we need to create graph page for each loop and then assign the page name as input for ogl.


for ( int i = 2; i <= 9; i++)
{
	win -t plot origin.otp graph$(i);
	doc -e W // loop all workbook in the project
	{
	plotxy (1,$(i)) plot:=200 ogl:=[graph$(i)]1!;
	}
}


James

alexapostu Posted - 07/08/2020 : 09:56:16 AM
range rSheet = $(page.active)!; //sheet
range rPage = rSheet.GetPage()$; //book;

for ( int i = 2; i <= 9; i++)
{
doc -e W // loop all workbook in the project
{
plotxy [%(rPage.name$)]%(rSheet.name$)!(1,$(i)) plot:=200 ogl:=1;
}
}


This is what I used but it doesn't do what I want. It creates 300 graph windows
YimingChen Posted - 07/08/2020 : 09:49:07 AM
Please use plotxy X-function to make plot, it has argument ogl to specify the graph layer to add plot to.
https://www.originlab.com/doc/X-Function/ref/plotxy

James
alexapostu Posted - 07/08/2020 : 09:18:08 AM
That doesn't help, actually it creates 300 new graphs and I only need 8
YimingChen Posted - 07/07/2020 : 08:52:36 AM
If you want to plot the i'th column of each worksheet into one graph, you may want to use the script below

for ( int i = 2; i <= 9; i++)
{
   doc -e W // loop all workbook in the project
   {
     range rr = 1!$(i); // data range of column i
    // Plot into one graph layer
   }
}


James

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