Author |
Topic  |
|
frijud
USA
4 Posts |
Posted - 05/08/2007 : 6:59:26 PM
|
Origin Version (Select Help-->About Origin): 7.5 Operating System:XPSP2
I have a unique job that I need Orgin to do. I have a set of data that is about 20 columns long. I want to automatically generate plots of:
A vs B A vs C A vs D ...and so on
and
B vs C B vs D ...and so on
Also, after these plot are generated, I want to plot:
A/B vs C/B A/B vs D/B ...and so on
and
A/C vs B/C D/C bs B/C ...and so on
I can do all of these plots manually, however it takes HOURS. Is there a way to program a macro to have it automatically generate these plots? Ideally, I would like a linear weighted least squares fit to each plot as well. |
|
Deanna
China
Posts |
Posted - 05/08/2007 : 11:42:48 PM
|
quote:
Origin Version (Select Help-->About Origin): 7.5 Operating System:XPSP2
I have a unique job that I need Orgin to do. I have a set of data that is about 20 columns long. I want to automatically generate plots of:
A vs B A vs C A vs D ...and so on
and
B vs C B vs D ...and so on
Hi, you can use the following Labtalk script to do the graphing and perform linear fit to each plot.
%l=%h; nWksCols=wks.nCols; for (ii=1; ii<=nWksCols; ii++) { for (jj=ii+1; jj<=nWksCols; jj++) { window -t p; %a= %(%l, $(ii)); %b= %(%l, $(jj)); layer.plotxy(%a, %b); layer -a; lr %c; //Linear fit label -s "Slope is $(lr.b), Intercept is $(lr.a)"; }; };
You can paste the code into the Script Window, highlight it and press Enter to execute it.
quote:
Also, after these plot are generated, I want to plot:
A/B vs C/B A/B vs D/B ...and so on
and
A/C vs B/C D/C bs B/C ...and so on
I am sorry. I don't quote understand what you mean by "A/C". Would you please explain?
Deanna OriginLab Technical Services |
 |
|
frijud
USA
4 Posts |
Posted - 05/09/2007 : 12:02:46 PM
|
Sorry, A/C vs B/C is column A devided by Column C vs Column B devided by Column B.
I need to do a mathmatical opperation then plot and do a linear fit of the data. I have also been looking at GNUplot. That program will do this qutie nicely, however it is rather hard to work with.
Thanks for you help!
|
 |
|
frijud
USA
4 Posts |
Posted - 05/09/2007 : 12:08:08 PM
|
Also, When I run the script on four columns of data, It generats one plot (A vs B). The other plots aren't there. In the scripts window, after the highlighted code, I get a line added that says "#Command Error!" I don't know what that means.
|
 |
|
frijud
USA
4 Posts |
Posted - 05/09/2007 : 2:53:42 PM
|
I was able to get the command error to go away by changeing the %c with a %b as shown in the code below:
%l=%h; nWksCols=wks.nCols; for (ii=1; ii<=nWksCols; ii++) { for (jj=ii+1; jj<=nWksCols; jj++) { window -t p; %a= %(%l, $(ii)); %b= %(%l, $(jj)); layer.plotxy(%a, %b); layer -a; lr %b; //Linear fit label -s "Slope is $(lr.b) sigma is $(lr.sdB); Intercept is $(lr.a) sigma is $(lr.sdA); R is $(lr.r), stdev of fit is $(lr.sd); number of points is $(lr.n)"; }; };
Now I just need to figure out how to do the mathmatical opperations. Any advice there? |
 |
|
larry_lan
China
Posts |
Posted - 05/09/2007 : 11:01:17 PM
|
Hi:
I am not sure what you mean "mathmatical opperations", if you want to calculate column A / column B, you can use:
col(c) = col(a)/col(b).
So you may need some more worksheets to save the result A/B, B/C, etc. Try the following script:
[main] %l=%h; nWksCols=wks.nCols; for (ii=2; ii<nWksCols; ii++) { run.section(, CreateDataWin); }; run.section(, PlotGraphs);
[CreateDataWin] jj = ii; win -t data origin; worksheet -a nWksCols-2-ii+1; nc = wks.ncols; for(kk=1; kk<=nc; kk++) { %(%h, kk) = %(%l, jj); jj++; }
win -a %l; worksheet -d; nc=wks.ncols; for(kk=1; kk<=nc; kk++) { %(%h,kk) = %(%h,kk) / %(%l,ii); }; delete %(%h, ii);
[PlotGraphs] doc -e w { %o = %h; nc = wks.ncols; for (nn=2; nn<=nc; nn++) { win -a %o; worksheet -s nn 0 nn 0; worksheet -p 201 scatter; lr %c; }; };
You can save the whole script as an .OGS file, such as test.ogs, and save this .OGS file to your Origin user folder. To run this .ogs file, type run.section(test, main) in the script window.
P.S. For 20 columns, it will generate hundreds of graph windows. Be careful 
Larry OriginLab Technical Services
Edited by - larry_lan on 05/09/2007 11:02:58 PM |
 |
|
|
Topic  |
|
|
|