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
 Graphing many columns of data?

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
hborck Posted - 08/21/2001 : 09:49:28 AM
I have a rather tricky script to write, and I cannot seem to get it to work...

I have a rather large collection of data (about 1000+ columns) and i need to graph every two columns seperately, i.e.: column 1 pairs with column 2, column 3 with column 4 and so on for the entire worksheet.

How would one do this? I cannot get the loop to cycle through the worksheet and am a little frustrated...

Thanks for the help.

----hborck
15   L A T E S T    R E P L I E S    (Newest First)
hborck Posted - 09/28/2001 : 1:47:16 PM
Thank you! That appears to work. I will update this thread later when I get the script working.

Thanks everyone!

UPDATE: it works (apparently)! Thanks again.
----------------------hborck

Edited by - hborck on 10/12/2001 10:43:53
CStorey Posted - 09/21/2001 : 5:37:13 PM
I see now. The problem is the use of the "work -s ...." command. All this does is select the data, not set the columns to be plotted. The command does not change the %C variable since it could be multiple columns.
Thus you cannot use the value of %L in the command to plot. You want to try something like:

win -a Data1; // Make "Data1" active
work -s $(1) 0 $(2) 0; // Select the range (c1 r1 c2 r2) to plot
work -p 202 linesymb; // 202, Line+symbol, linesymb template
See the Help file section "Worksheet Command" -p option for a list of plot types and templates available.

Hope this helps.

Craig Storey
Origin WebRing Member - http://nav.webring.yahoo.com/hub?ring=originwebring
hborck Posted - 09/21/2001 : 3:21:51 PM
I removed the %B and am using %L now instead. I tried several variations of your suggested change, and still the graph is blank...

nuts.-------------hborck
CStorey Posted - 09/21/2001 : 2:33:49 PM
Hmmm. Try this:

window -t plot "C:\Program Files\OriginLab\Origin61\templates\graphtemplate" graphname;

work -s $(1) 0 $(2) 0;
%B=%C;
type "%B";
win -a graphname; // Make the graph opened by win -t the active window.
layer -i %B;
layer -a;

I think %B (not a good choice for a string varible name since it's modified by many Origin routines) is getting changed by the "win -t" command. I would try this and in future avoid the reserved strings (%A, %B, %C, %G, %H, %X, %Y) except for there intended use. Take a look at the end of - http://www.genevalake.ca/origin/origin_intro.html - for more info. You might also want to look at http://www.genevalake.ca/origin/originlabtalk.html and http://www.genevalake.ca/origin/labtalk_handy.html for some useful utilities and code.

Craig Storey
Origin WebRing Member - http://nav.webring.yahoo.com/hub?ring=originwebring

Edited by - CStorey on 09/21/2001 14:35:45
hborck Posted - 09/21/2001 : 1:56:46 PM
Thanks CStorey, I got the "test" script to work, so the problem must be within my %B assignment. What could be wrong?

----------------hborck
CStorey Posted - 09/21/2001 : 1:05:28 PM
To read the first 3 rows in a single column into a string variable use:

%U=wcol(jkl-1)[1]$; //Get first row text
%A=wcol(jkl-1)[2]$; //Get 2nd row text
%U=%U\r\n%A; //Append 2nd to first with a CRLF (\r\n)
%A=wcol(jkl-1)[3]$; //Get 3rd row
%U=%U\r\n%A; //Append it to 1 & 2
type -b %U; //Diplay the results

I believe the answer to your second question lies with the %B var. Make sure it that %B has a value, because the command "layer -i" without a dataset name means erasse all datasets from the graph.

Try a simple test like creating a wks called Data1 fill column A with row indices and col B with random numbers. Create a plot called Graph1. Then try:

%B="Data1_B"; // Column B
type -b "About to plot %B!"; // Message box
win -a Graph1; // Graph1 as active window
layer -i %B; // Plot column Blayer -a; // Rescale layer.

Hope this helps.


Craig Storey
Origin WebRing Member - http://nav.webring.yahoo.com/hub?ring=originwebring
hborck Posted - 09/21/2001 : 11:20:15 AM
Sorry, one more thing:

I am working through the code piece by piece, and this does not work for me:

work -s $(1) 0 $(2) 0;
%B=%C;

type "%B";

window -t plot "C:\Program Files\OriginLab\Origin61\templates\graphtemplate" graphname;
layer -i %B;
layer -a;

This supposedly should create the graph, which it does, but nothing is plotted!

---------hborck the confused newbie
hborck Posted - 09/21/2001 : 10:59:03 AM
quote:


The use of worksheet -select is not correct for what seems to be intended. The values of %A, %B and %D will all be the same since %C (the active dataset) is not changed in any way. You can read a text value from a cell with something like:

%A=wcol(jkl-1)[3]$;





How would you manipulate the line above to take in several subsequent rows from the same column into 1 variable? I.e.:

If the first 3 rows look like:

row1
row2
row3

I would like to be able to aotomatically have those three rows become the title of the graph in question, but with the same "look", therefore I need a string variable that looks like

row1
row2
row3

when outputted. Is this possible?

Thanks
hborck
greg Posted - 09/14/2001 : 11:55:32 AM
I see three problems:


  1. To begin with, the for loop has completely run its course before the intended script even begins and the value of jkl is already over limit. This happens because of the semi-colon at the end of:

    For(jkl=2; jkl<=wks.ncols; jkl=jkl+2);

    In essence, you are running an empty for loop and then executing some more code.


  2. The use of worksheet -select is not correct for what seems to be intended. The values of %A, %B and %D will all be the same since %C (the active dataset) is not changed in any way. You can read a text value from a cell with something like:

    %A=wcol(jkl-1)[3]$;


  3. Finally, the worksheet -type command does not create a graph; perhaps you meant to use: window -t plot ...

Tip:

The window -t plot ... command searches in the Origin folder if no path information is specified. If you do need to specify a path and (as this user has) you use a subfolder of Origin, you can use %Y (the Origin path) as in:

win -t plot %YTemplates\GraphTemplate;



hborck Posted - 09/14/2001 : 10:19:39 AM
I still cannot get it to work, even with Mike's suggestion. Any ideas?

Here is the reviesed code:


// set active window back to worksheet;
win -a ABSdata1;

//start the loop;

For(jkl=2; jkl<=wks.ncols; jkl=jkl+2);
{
// Set the 1st column to X-type.;
wks.col$(jkl-1).type=4;
//set next to Y-type;
wks.col$(jkl).type=1;

//grab the necessary data for labeling;
work -s $(jkl-1) 3 $(jkl-1) 3;
%A=%C;
work -s $(jkl-1) 1 $(jkl-1) 3;
%D=%C;

//select columns with row depth 0 to get ALL rows;
work -s $(jkl-1) 0 $(jkl) 0;
//and copy the data;
%B=%C;

//plot to saved template;
work -t plot "C:\Program Files\OriginLab\Origin61\templates\graphtemplate" graphname;
layer -i %B; // include worksheet selection (%B) into layer ;
layer -a; // rescale layer

//select the new plot;
win -a graphname;
win -r graphname %A;

//change plot data;
label -n text %D;

//go back to the worksheet to iterate;
win -a ABSdata1;
};
type "done";


Thanks again,

Hans
Mike Buess Posted - 09/07/2001 : 3:41:21 PM
I don't know if this will fix everything, but I think your notation is wrong in the work -s commands. They should probably read like this:

//grab the necessary data for labeling;
work -s $(jkl-1) 3 $(jkl-1) 3;
%A=%C;
work -s $(jkl-1) 1 $(jkl-1) 3;
%D=%C;

//select columns with row depth 0 to get ALL rows;
work -s $(jkl-1) 0 $(jkl) 0;
//and copy the data;
%B=%C;

In other words, "$" should be outside of the parenthesis. $(x) expresses the value of x as a string. I hope that helps.

Mike Buess
Origin WebRing Member
hborck Posted - 09/07/2001 : 2:08:24 PM
nuts, can someone point out what i am doing wrong here?

// set active window back to worksheet;
win -a ABSdata1;

//start the loop;

For(jkl=2; jkl<=wks.ncols; jkl=jkl+2);
{
// Set the 1st column to X-type.;
wks.col$(jkl-1).type=4;
//set next to Y-type;
wks.col$(jkl).type=1;

//grab the necessary data for labeling;
work -s ($jkl-1) 3 ($jkl-1) 3;
%A=%C;
work -s ($jkl-1) 1 ($jkl-1) 3;
%D=%C;

//select columns with row depth 0 to get ALL rows;
work -s ($jkl-1) 0 $jkl 0;
//and copy the data;
%B=%C;

//plot to saved template;
work -t plot "C:\Program Files\OriginLab\Origin61\templates\graphtemplate" graphname;
layer -i %B; // include worksheet selection (%B) into layer ;
layer -a; // rescale layer

//select the new plot;
win -a graphname;
win -r graphname %A;

//change plot data;
label -n text %D;

win -a ABSdata1;
}

this script is not doing anything. I have borrowed from both the above.

again, much thanks...

--------------hborck
hborck Posted - 09/07/2001 : 2:01:27 PM
thanks! I almost have it working the way I want it to. If I run across anymore trouble, I will let you know...
rtoomey Posted - 08/21/2001 : 1:59:21 PM
Craig's solution is good. It might be worth mentioning that his script has been organized into sections. The best way to utilize this type of organization would be to save the script as an OGS (Origin Script) file and then call the appropriate section of that OGS file to get things running. In other words, do the following:

  1. Select File | Save As from the editor being used to create the script.
  2. Navigate to the Origin installation folder and save it as MyFile.OGS (where MyFile is up to you).
  3. Return to Origin and open the Script window (select Window | Script Window).
  4. Type in something similar to the following:

    run.section(MyFile,GraphIt);

  5. Highlight what you have typed and press the ENTER key on your keyboard to execute it.

    Note: Craig's script assumes that a worksheet called Data1 is where the data resides.




If you don't want to work with an OGS file or want a simpler version of the script, try this one out:

%A=%H; // store worksheet name in %A for later
for(ii=2; ii<=wks.ncols; ii+=2)
{
wks.col$(ii-1).type=4;
// set 1st column in each group of 2 to X
worksheet -s ii 0 ii 0; // select Y column
%B=%C; // store worksheet selection in %B for later
win -t plot Origin GraphName$(ii); // create graph using Origin graph template
layer -i %B; // include worksheet selection (%B) into layer
layer -a; // rescale layer
win -a %A; // activate worksheet again to continue looping
};


Notes about my version:

1) GraphName can be changed to whatever you like.
2) The worksheet containing the data to be plotted must be the active window.
3) Once the script has been pasted into the script window, highlight it and press the ENTER key on your keyboard to execute it.
4) The Origin.OTP graph template is used. When including data into this template, the data will come in as black line plots by default. To obtain a differnent plot type, use another built-in template or create your own user-defined template. Whatever template you decide to use, make sure that its name replaces the word "Origin" in the script.
CStorey Posted - 08/21/2001 : 11:28:41 AM
I would try something like this:

[GraphIt]

win -t plot; /// Open a new graph window from custom template here;
%R=%H; /// Remember the Graph's Name
win -a Data1; /// Set current worksheet
%W=%H; /// Remember the Worksheet's Name

For(jkl=2; jkl<=%W!wks.ncols; jkl=jkl+2)
{
wks.col$(jkl-1).type=4; /// Set the 1st column to X-type.
%U=%(%W,jkl);
run.section(, Plot, %R %U jkl 1 200); /// Plot column as a line in layer1
// run.section(, Plot, %R %U jkl jkl/2 201); /// Plot column with symbols in layer N
};
win -a %R;
Rescale;
legend;
Return;

//**********************************************************************************//
// Plotting Routine
// Inputs: %1=Plot name, %2=Wks column, %3=colour
// %4=destination layer, %5=symbol type
//**********************************************************************************//
[Plot]

#!type " -->Plotting (Gph=%1 + Column=%2 + C#=%3 + Line#=%4 + Type#=%5)";
win -o %1 {
layer -i%5 %2; //Add layer to graph
set %2 -c %3; //Colour of line + symbol (%5)
if(%4>=12) set %2 -d 2; //Doted lines after 12 colored ones,
if(%4>=24) set %2 -d 1; //then Dashed lines.
};
#!type " -->Plotting...Done!";
Return;
//**********************************************************************************//


Craig Storey
Origin WebRing Member - http://nav.webring.yahoo.com/hub?ring=originwebring

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