| T O P I C R E V I E W |
| bg-phys |
Posted - 07/21/2006 : 4:20:51 PM Origin Version: v7.5 SR5 Operating System: Win XP
For some reason I am having trouble using the set command from a labtalk script. (*.ogs file) I have two Origin worksheets (*.txt files) open. I have renamed them "Right" and "Left". They should have the same dimensions. Each column in the Right and Left windows is a set of Y data.
Then I create another worksheet called "Xaxis". "Xaxis" has two columns of x-axis data.
For each column in Left and Right I want two graphs: (Do they need to be in seperate layers?)
Graph 1, Layer 1: (Xaxis Column 1) vs (Left Column jj) Graph 1, Layer 2: (Xaxis Column 1) vs (Right Column jj)
Graph 2, Layer 1: (Xaxis Column 2) vs (Left Column jj) Graph 2, Layer 2: (Xaxis Column 2) vs (Right Column jj)
The following code works for me:
set Left -c 2; // Set plot line color to red set Right -c 1; // Set plot line color to black
The following did not work for me:
for(jj=1; jj<nC; jj++) // nC: number of columns { %A=tofPlot$(jj); // Specify output graph name and set it to variable "%A" win -t plot scatter %A; // Open a new scatter plot window called %A
label -xb "tof [ns]"; label -yl "Intensity"; 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; // Set Y-axis to start at 0 layer.y.to=40000; // Set Y-axis to end at 40000 layer -n Both; // Show top X-axis & right Y-axis
win -a Xaxis;
//here's the part that doesn't work:
set Left!wcol(jj) -x wcol(1); set Right!wcol(jj) -x wcol(1);
//So I never get to here: win -a %A; // Reactivate the graph window layer -i %(Left, jj); // Plot the dataset layer -i %(Right, jj); // Plot the dataset
//And I'm not sure about this part:
sec -p 1; // Pause, this is necessary to wait till the graph is ready image.filename$=O:\Origin\%A.gif; //Specify the output filename image.export.pagepixel(gif,640,480,24,0); //Specify output graph pixel resolution win -cd %A; // Close the worksheet and delete all of its data.
} //Eventually I'll want to make another graphy with Xaxis column 2
The names of the columns in Right and left are the default: "A B C1 C2 C3 ...". So it would be awkward to use the column names. This is why I opted for "wcol(jj)" so I could use the column number instead. I have also tried:
set %(Left, jj) -x %(Xaxis, 1);
Thanks in advance for any input.
|
| 5 L A T E S T R E P L I E S (Newest First) |
| Mike Buess |
Posted - 07/25/2006 : 2:59:14 PM quote: What is the "%(1, @D)" and "%(1, @D)" in the following code...
This is syntax for obtaining dataset names in a graph layer. %(2, @D) is the name of the 2nd dataset plotted in the active layer.
quote: This is everything I want except I would like to move the tick marks that are on the outside (upper side) of the top x-axis to the inside (lower side).
layer.x.ticks and layer.y.ticks adjust ticks on bottom and left axes. Use layer.x2.ticks and layer.y2.ticks to adjust ticks on top and right axes.
quote: but I'm afraid I'm not using the open command properly.
You are using a multiple file selection dialog (getfile -m) to select a single file, which works but is unnecessary. And %B is the file path, file name is %A. Try this...
%B=""; type -b "Choose Left data file."; win -n data Left; win -a Left; getfile *.txt; // %A is file name, %B is file path (with trailing \) type -a "1"; open -w %B%A; type -a "2";
Mike Buess Origin WebRing Member |
| greg |
Posted - 07/25/2006 : 2:51:20 PM Here is the proper use of the -m option for getfile:
getfile -m *.txt; loop(ii,1,count) { getfile -g ii; // gets filespec for the 'ii'th file into %A ... ... }
So you would need to manage worksheet windows in your case. For two windows that might be:
// type -b "Choose Left data file."; win -n data Left; win -a Left; getfile -m *.txt; // this selects multiple files type -a "1"; getfile -g 1; // Get the first selected file into %A open -w %A; type -a "2"; // type -b "Choose Right data file."; win -n wks Right; win -a Right; getfile -g 2; // Get the second selected file into %A open -w %A;
|
| bg-phys |
Posted - 07/25/2006 : 1:17:32 PM One more question:
I'm trying to create a section that will: - prompt the user to locate the data files to open - Import the data into worksheets - name the worksheets "Left" and "Right"
This is my code, but I'm afraid I'm not using the open command properly because All I get is a blank white background in the "Left" window. The type -a "2"; command never executes.
[LoadDataFiles] %B=""; type -b "Choose Left data file."; win -n data Left; win -a Left; getfile -m *.txt; type -a "1"; open -w %B; type -a "2";
%B=""; type -b "Choose Right data file."; win -n wks Right; win -a Right; getfile -m *.txt; open -w %B;
|
| bg-phys |
Posted - 07/25/2006 : 12:23:49 PM Thanks very much for the Help! I do have a couple quick questions though:
What is the "%(1, @D)" and "%(1, @D)" in the following code. I've looked through the documentation on substitution notation, but this doesn't look quite like any of the formats mentioned. Specifically, what is the function of "@D" in this notation?
set %(1, @D) -c 1; set %(2, @D) -c 2;
Also, on the top and bottom x-axes I wish to display major and minor ticks on the inside of the axes.
On the left y-axis I wish to display major and minor ticks on the inside of the axis. On the right y-axis I wish to display no tick marks.
I have tried the following:
win -t plot line; //(I'm using a line plot now) layer.x.ticks=5; layer.y.ticks=10;
I place this code before looping through each column to create each individual graph. It seems that this code should give me what I want everywhere except the right y-axis. But the axes that I get are as follows.

This is everything I want except I would like to move the tick marks that are on the outside (upper side) of the top x-axis to the inside (lower side).
Also, these axes are the same ones I got before I inserted the layer.axis.ticks code. So I suppose I should remove the layer.y.ticks=10; statement and focus on modifying the top x-axis. But how do I do that?
Edited by - bg-phys on 07/25/2006 12:27:37 PM |
| Mike Buess |
Posted - 07/22/2006 : 11:16:58 PM First, a few corrections...
1. I doubt that set Left -c 2 really works... first argument should be a dataset, not worksheet.
2. layer -n Both does not show top X and right Y axes in the active layer. It creates a linked layer with axes on the top and right. Use this instead...
layer.x.showaxes=3; // show both X axes in active layer layer.y.showaxes=3; // show both Y axes in active layer
3. wksName!wcol(jj) is not the proper way to address column jj in worksheet wksName. Use %(wksName,jj) instead.
4. The Programming Guide says that a graph window must be active when you use the set command with the -x option so activating the Xaxis worksheet (win -a Xaxis) guarantees failure.
That said, I confess that I can't make set's -x option work either :) and suggest instead that you copy the Xaxis columns to the Left and Right worksheets. I'm guessing that you are interested more in the gif exports than the actual graph windows so the script below recycles a single graph window to speed up the operation. Copy both script sections to your script file FileName.OGS, save and enter the command run.section(FileName,Main) in the script window.
[Main] if( Left!wks.col1.type!=4 ) { Left!wks.col=1; Left!wks.insert(Xaxis); // insert column in first position Left!wks.col1.type=4; // make it an X column }; if( Right!wks.col1.type!=4 ) { Right!wks.col=1; Right!wks.insert(Xaxis); // insert column in first position Right!wks.col1.type=4; // make it an X column }; nC = Left!wks.ncols; win -t Plot scatter; label -xb "tof [ns]"; label -yl "Intensity"; 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; // Set Y-axis to start at 0 layer.y.to=40000; // Set Y-axis to end at 40000 layer.x.showaxes=3; // show both X axes layer.y.showaxes=3; // show both Y axes %B=O:\Origin\; // Output path image.showOptions=0; // hide options dialog run.section(,Export,1); run.section(,Export,2); win -c %H; // delete active graph window
[Export] %(Left,1)=%(Xaxis,%1); // copy data from column %1 of Xaxis wks %(Right,1)=%(Xaxis,%1); for(jj=2; jj<=NC; jj++) { %Z=""; layer -c; // count dataplots if( count ) layer -e %Z; // remove dataplots %A=tofPlot$(jj)_%1; layer -i %(Left,jj); layer -i %(Right,jj); set %(1, @D) -c 1; set %(2, @D) -c 2; sec -p 0.1; // 1s is probably longer than necessary image.filename$=%B%A.gif; //Output filename image.export.pagepixel(gif,640,480,24,0); //Specify output graph pixel resolution };
Mike Buess Origin WebRing Member
Edited by - Mike Buess on 07/22/2006 11:37:55 PM |
|
|