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
 multiple plot from Lab Talk

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
baggio2008 Posted - 02/17/2016 : 05:43:10 AM
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
5   L A T E S T    R E P L I E S    (Newest First)
Hideo Fujii Posted - 02/19/2016 : 10:54:51 AM
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
baggio2008 Posted - 02/18/2016 : 3:12:16 PM
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.
Hideo Fujii Posted - 02/18/2016 : 11:34:47 AM
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
baggio2008 Posted - 02/18/2016 : 09:34:22 AM
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.
Hideo Fujii Posted - 02/17/2016 : 2:22:49 PM
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

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