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
 multiple plot from Lab Talk
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

baggio2008

Germany
4 Posts

Posted - 02/17/2016 :  05:43:10 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): 8
Operating System: Win7


Hello,
I'm very new in Lab talk programming and I want to write a lab talk-script to plot many graphs according to the data attached the plot example is also attached. how could I proceed.
I'm thank you for your help.
baggio

Edited by - baggio2008 on 02/24/2016 03:50:22 AM

Hideo Fujii

USA
1582 Posts

Posted - 02/17/2016 :  2:22:49 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi baggio2008,

If the number of datasets to be plotted is not many, and you know their positions, you can run the
following x-function (assuming that the column designations have been properly set):
  plotxy ((3),(7)) plot:=202;
Or, in the case of short names,
  plotxy ((C),(G)) plot:=202;

(Here, "plot" indicates the the plot type: Line=200, Scatter=201, Line+Symbol=202, Column=2013, StackCol=213, etc.)

If you want to plot multiple datasets in more general way like plotting from columns with a same
long name, you need to brush up the script
a bit more such as:
////////////////////////////////////////////
function string collectcols(string strVal) {
  ncol=wks.ncols;
  collectii$="";
  ntok=0;
  for(ii=1; ii<=ncol; ii++) {
    Lstr$=wcol(ii)[L]$;
    //pos = Find(Lstr$,strVal$);  //WildCard not usable
    pos = MatchBegin(Lstr$,strVal$,1,1); //WildCard OK, StartPos=1, Case sensitive=1
    if(pos>0) {
      ntok++;
      if(ntok==1) collectii$="("+"$(ii)"+")";
      else        collectii$=collectii$+","+"("+"$(ii)"+")";
    }
  }
  return collectii$;
}

//// Make a plot from the columns with a same long name
plotxy (%(collectcols("RElyt")$)) plot:=202 ogl:=<new template:=Origin>
////////////////////////////////////////////

I hope this helps your work.

--Hideo Fujii
OriginLab

Edited by - Hideo Fujii on 02/17/2016 2:30:30 PM
Go to Top of Page

baggio2008

Germany
4 Posts

Posted - 02/18/2016 :  09:34:22 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello Hideo Fujii,
thank you for the reply. I tried your code but it didn't work.

According to the image attached,
I wanted for the active sheet and active book 4 graphs at once to plot.
I used as example for plotting 2 graphs the following codes:
plotxy iy:=((2,3),(2,7),(2,11),(2,15),(2,19),(2,23), (2,27)) plot:=202 ogl:=1;
plotxy iy:=((2,4),(2,8),(2,12),(2,16),(2,20),(2,24), (2,28)) plot:=202 ogl:=2!;

but only one graph is plotted. the second was not found. Better will be to use loop for plotting but i don't know how.
Could somebody make a suggestion.
Thank you.
Go to Top of Page

Hideo Fujii

USA
1582 Posts

Posted - 02/18/2016 :  11:34:47 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi baggio2008,

> plotxy iy:=((2,3),(2,7),(2,11),(2,15),(2,19),(2,23), (2,27)) plot:=202 ogl:=1;
> plotxy iy:=((2,4),(2,8),(2,12),(2,16),(2,20),(2,24), (2,28)) plot:=202 ogl:=2!;
> but only one graph is plotted.

Without specifying the book and sheet, it assumes the current worksheet, and after
the first plotxy, the active window is switched to the newly created graph window.
So, you should keep the workbook name, and specified it in plotxy like:
wn$=%H; //workbook name
plotxy iy:=[wn$]1!((1,2),(1,3)) plot:=202 ogl:=<new template:=myStack2>;
gn$=%H; //graph window name
plotxy iy:=[wn$]1!((1,4),(1,5)) plot:=202 ogl:=[gn$]2!;
Note: As I imagined that you wanted to make the 2nd plots not overlapped to the first layer,
I specified a custom template name in the above snippet.

--Hideo Fujii
OriginLab

Edited by - Hideo Fujii on 02/18/2016 11:36:44 AM
Go to Top of Page

baggio2008

Germany
4 Posts

Posted - 02/18/2016 :  3:12:16 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello Hideo Fujii,
thank you for your suggestion its works well.I have another question. How would be the code if i want to use a loop to plot the 4 graphs (tracking specific columns). Thanks.
Go to Top of Page

Hideo Fujii

USA
1582 Posts

Posted - 02/19/2016 :  10:54:51 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi baggio2008,

You can use Doc -e command to scan every Y dataset in a worksheet. For the details, see:
http://www.originlab.com/doc/LabTalk/ref/Document-cmd#-e_object_.7Bscript.7D.3B_Execute_the_given_script_for_all_objects

like:
wn$=%H; //workbook name
Doc -e DY { //scan current worksheet to get every Y column
  %K=%C;
  //window -t plot; //if you want to create a new graph every time
  ds$=Token(%K,2,'_')$; //get the column short name
  plotxy iy:=[wn$]1!ds$ plot:=202 ogl:=1; //plot into the 1st layer
}
Hope this can help.

--Hideo Fujii
OriginLab

Edited by - Hideo Fujii on 02/19/2016 10:55:19 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