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
 Animation - graph creation and export in quantity
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

hillisd@unr.nevada.edu

USA
Posts

Posted - 07/11/2006 :  5:06:39 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin): 7.5
Operating System:Windows XP
Sorry for the simplicity of my question but I am new to the program. I have a .txt file which consists of 16 columns and 20000 rows. Each row will create a 2d graph consisting of 8 points. Each data point is independent of the others. A graph must be created for all 20000 rows then exported to a file, so the .gif format files can be combined into a single animation .gif file. I am a novice on the programming. I am hoping someone has completed a similar task and could give me some advice. Thank you for your help.

larry_lan

China
Posts

Posted - 07/12/2006 :  03:05:09 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi:

Suppose your data is organized by XYXYXY... in each row, my idea is, extract data from each row and rearrange it like:
XY
XY
XY
...
to plot the graph. Here is my labtalk script, and suppose Data1 is the original data worksheet.

/////////////////////////////////////////////

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; // Set the layer scale

sec -p 1; // Pause, this is necessary to wait for the graph is ready
image.filename$=d:\test\%B.gif; // Specify the output file name and path
image.export.pagepixel(gif,640,480,24,0); // Specify the output graph pixel resolution

win -cd %B;
win -cd %A;
}


Larry
OriginLab GZ Office

Edited by - larry_lan on 07/12/2006 03:07:05 AM
Go to Top of Page

bg-phys

USA
Posts

Posted - 07/19/2006 :  11:36:11 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply

//I have added some comments to the code for clarity.
//If any comments are misleading please correct them and repost.



// This is a comment.
/* This is a multi-line comment.
* It has two lines. */


win -a Data1; // Set Data1 as the active window.
// This also Restores the "Data1" window if it was minimized.
nR=wks.nRows; // Set variable "nR" and "nC" to the number of rows and
nC=wks.nCols; // colums (respectively) in the current worksheet


/* Loop over all rows. */
loop(ii, 1, nR) // 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;


/* Loop over all columns. */
for(jj=1; jj<nC; jj=jj+2)
{
// %A = worksheet
// %A_A = column A of worksheet
// %A_A[5] = 5th row element of column A of worksheet


/* col()[] is of the form: col(colName)[row#]
* col()[] returns the numeric value of the dataset item specified.
* Since no dataset is specified when we use it below, the command uses
* the dataset in the active window. We have just set the active window
* to Data1 a few commands ago.
*/


/* Now we take the data from the Data1 dataset and put it in the %A
* dataset. We do this one data element at a time.
*/
%A_A[$(kk)]=col($(jj))[$(ii)];
%A_B[$(kk)]=col($(jj+1))[$(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 1
layer.y.from=0; // Set Y-axis to start at 0
layer.y.to=40000; // Set Y-axis to end at 1


sec -p 1; // Pause, this is necessary to wait for the graph is ready
image.filename$=d:\test\%B.gif; // Specify the output file name and path
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.
}




Edited by - bg-phys on 07/19/2006 11:46:54 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