| Author |
Topic  |
|
|
elena_loginova
USA
Posts |
Posted - 10/28/2008 : 5:39:08 PM
|
Origin Version 8.0 Operating System:Windows XP
Hi everybody, I am new to LabTalk. I am trying to write a script that would plot XY-graphs adding one more point on every next plot and save them as images. I am going to use these images for animation of the plot as Y changes as function of X. I found few topics about it. As I understand the idea: I have to create a new whorksheet and copy my XY data there in a loop with addition of the next point. I adapted the script posted by bg-phys on 07/19/2006 at 11:36:11 AM (see below). Unfortunately it doesn't work. I appreciate any suggestions or comments. Thank you in advence! Elena. ---------- win -a Data1; // Set Data1 as the active window.
/* Loop over all rows. */ loop(ii, 1, 1067) // just like for(ii=1; ii<nR; ii=ii+1) {
%A=MyWks$(ii); // Sets string variable "%A" to "MyWks" // with the value of ii appended to it. (i.e. MyWks1) win -t wks origin %A; // Open a new worksheet called %A win -a Data1; // Set Data1 as the active window. kk=1;
%A_A[$(kk)]=col($(1))[$(ii)]; %A_B[$(kk)]=col($(2))[$(ii)]; kk++; // same as "kk=kk+1;" which is the same as "kk+=1;" }
%B=MyPlot$(ii); // Specify output graph name and set it to variable "%B" win -t plot scatter %B; // Open a new scatter plot window called %B layer -i %A_B; // Plot dataset %A_B layer.x.from=0; // Set X-axis to start at 0 layer.x.to=100; // Set X-axis to end at 100 layer.y.from=0.01; // Set Y-axis to start at 0.01 layer.y.to=0.04; // Set Y-axis to end at 0.04
sec -p 1; // Pause, this is necessary to wait for the graph is ready image.filename$=C:\Work\animation\%B.gif; image.export.pagepixel(gif,640,480,24,0); // Specify the output graph pixel resolution
win -cd %B; // Close the worksheet and delete all of its data. win -cd %A; // Close the worksheet and delete all of its data. |
|
|
elena_loginova
USA
Posts |
Posted - 10/28/2008 : 7:04:37 PM
|
Hi,
I found a typo in my previous script. Now it works:
win -a Data1; nR=wks.nRows; nC=wks.nCols;
loop(ii, 1, nR) { %A=MyWks$(ii); win -t wks origin %A; win -a Data1; kk=1; for(jj=1; jj<nC; jj=jj+2) { %A_A[$(kk)]=col($(jj))[$(ii)]; %A_B[$(kk)]=col($(jj+1))[$(ii)]; kk++; } %B=MyPlot$(ii); // Specify output graph name win -t plot scatter %B; layer -i %A_b; layer.x.from=0; layer.x.to=1; layer.y.from=0; layer.y.to=1; sec -p 1; image.filename$=d:\test\%B.gif; image.export.pagepixel(gif,640,480,24,0); win -cd %B; win -cd %A; }
I have another question though. Could anybody tell me how I can apply a desired template for graphs in my script? Thank you. Elena. |
 |
|
|
elena_loginova
USA
Posts |
Posted - 10/28/2008 : 9:41:43 PM
|
Hi,
I apologize for the spam. I solved my problems with the script. In case someone needs a script to plot an accumulative graph point by point, here it is:
win -a Data1; nR=wks.nRows; nC=wks.nCols; %A=MyWks$(ii); win -t wks origin %A; kk=1; loop(ii, 1, nR) { win -a Data1; for(jj=1; jj<nC; jj=jj+2) { %A_A[$(kk)]=col($(jj))[$(ii)]; %A_B[$(kk)]=col($(jj+1))[$(ii)]; kk++; } %B=image0000$(ii); // Specify output graph name win -t plot "C:\Program Files\OriginLab\LINE.otp" %B; layer -i %A_b; layer.x.from=-100; layer.x.to=1300; layer.y.from=0.017; layer.y.to=0.038; // Set the layer scale sec -p 1; image.filename$=C:\Work\animation\%B.png; image.ShowOptions=0; image.export.pagepixel(png,1024,768,24,0); win -cd %B; }
win -cd %A;
|
 |
|
| |
Topic  |
|
|
|