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
 LabTalk Forum
 Plot different columns from different workbooks
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

alexapostu

Romania
10 Posts

Posted - 07/05/2020 :  11:36:08 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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
};

YimingChen

1666 Posts

Posted - 07/07/2020 :  08:52:36 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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

Edited by - YimingChen on 07/07/2020 08:57:06 AM
Go to Top of Page

alexapostu

Romania
10 Posts

Posted - 07/08/2020 :  09:18:08 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
That doesn't help, actually it creates 300 new graphs and I only need 8
Go to Top of Page

YimingChen

1666 Posts

Posted - 07/08/2020 :  09:49:07 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

alexapostu

Romania
10 Posts

Posted - 07/08/2020 :  09:56:16 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

YimingChen

1666 Posts

Posted - 07/09/2020 :  2:03:26 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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

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