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
 Displaying vaules from a worksheet onto a graph!!!
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

dean.pask

UK
Posts

Posted - 10/14/2005 :  11:13:12 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin): 7.5 Pro
Operating System: XP

Hi,

Please can anyone advise how to take a value from a worksheet (ie column B row 3) and display this onto a graph in a position defined by the user.

Have a great weekend all.

Dean

Mike Buess

USA
3037 Posts

Posted - 10/15/2005 :  11:28:08 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Dean,

Use the label command to create a text label with the message you want. Each text label is given a unique name like Text, Text1, Text2, etc. and you can move the center of the label to a given set of graph coordinates using the standard object properties labelName.x and labelName.y. The following script creates a text label containing the cell value in row 3, column 2 of Data1. It then finds the name of the label and positions it at coordinates xx and yy. I assume that this is in reference to your peak labelling question in another topic, in which case xx is the peak position and yy is the peak height. Since you will want the text label to appear above the peak I've raised its center position from yy to yy + labelHeight, or yy + labelName.dy.

%W=Data1; // wks name
label -s $(%W!cell(3,2)); // create text label
doc -e G {
// find its name - will be the first match encountered
if("%[%B,5]"=="text") break;
};
%B.x = xx; // move center of label to X = xx
%B.y = yy + %B.dy; // move center to Y = yy + labelHeight


LabTalk Language Reference > Command Reference > Alphabetical Listing > Document and Label

LabTalk Language Reference > Object Reference > Internal Object Overview > User-created Visual Objects

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 10/15/2005 11:34:11 AM
Go to Top of Page

dean.pask

UK
Posts

Posted - 10/18/2005 :  09:51:30 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Mike,

Looks like it works almost.. It takes my Data from FFT data wks although it then displays the result on that FFT data wks.. Do I need to make the graph the current active item to display it on there?

My deepest thanks as ever.

Dean

Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 10/18/2005 :  10:32:44 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Dean,

Yes, the graph window must be active. Following script assumes graph is active and peak X&Y are stored in columns Pkx&Pky of FFT wks.

%W=%[%C,'_']; // get name of the FFT wks from active dataplot
if( exist(%W_Pkx,1)==0 ) {
ty -a No peaks!;
return;
};
get %W_Pkx -e nPeaks; // # of peaks
if( nPeaks==0 ) {
ty -a No peaks!;
return;
};
loop (ii,1,nPeaks) {
xx=%W_Pkx[ii]; // pk position
yy=%W_Pky[ii]; // pk height
label -s $(xx); // create text label
doc -e G {
// find its name - will be the first match encountered
if("%[%B,5]"=="text") break;
};
%B.x = xx; // move center of label to X = xx
%B.y = yy + %B.dy; // move center to Y = yy + labelHeight
};

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 10/18/2005 10:48:59 AM
Go to Top of Page

dean.pask

UK
Posts

Posted - 10/23/2005 :  10:45:07 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hay Mike,

Using the code below leaves me with the FFT of Data1 (first run) as the open window.... How do I reopen the fft graph which is the one before this?

Thanks again.

%L=%H; // save its name
wks.col1.type=4;
worksheet -s 2 0 2 0;
worksheet -p 200 Origin;

layer -a;
window -t W FFT;
%F=%H; // save its name
page.label$=FFT of %L; // identify Labview data in label
page.title=3; // show label

fft.reset();
fft.forward = 1;
fft.forward.timeData$ = %L_A;
fft.forward.tdelta = %L_A[2] - %L_A[1];
fft.forward.realData$ = %L_B;
fft.output.samplingdata$ = %F_Freq;
fft.output.realdata$ = %F_Real;
fft.output.imagdata$ = %F_Imag;
fft.output.ampdata$ = %F_r;
fft.output.phasedata$ = %F_Phi;
fft.output.powerdata$ = %F_Power;
fft.real = 1;
fft.normalize = 1;
fft.shifted = 1;
fft.windowing = 1;
fft.spectrum = 1;
fft.unwrap = 1;
fft.forward();


worksheet -s 4 0 4 0;
worksheet -p 200 Origin;
layer1.y.from = 0;
layer1.x.from = 0;
layer1.x.to = 3E9;
layer1.y.to = 10;

nPeaks=5;
%B=%F_r;
win -t D; // create temporary wks
%W=%H; // save its name
wks.addcol(Pki); // add col for peak indices
curve.pickpeaks.simple=1;
curve.reset();
curve.data$=%B;
curve.peakIndex$ = %W_Pki;
curve.pickPeaks.rectHeight = 0.005;
curve.pickPeaks.rectWidth = 0.005;
curve.pickPeaks.minHeight = 0.005;
curve.pickPeaks(1);

get %W_Pki -e end;
if(end==0) {
type -a No peaks were found.;
win -cd %W;
return;
};

nn=0;
for(ii=1;ii<=end;ii++)
{
index = %W_Pki[ii];
xx = xvalue(index,%B);
if( xx<0 ) continue;
nn++;
%W_A[nn] = xx;
%W_B[nn] = %B[index];
};
type -a $(nn) peak/s were found;

if(nn>nPeaks)
{
sort -wd %W %W_B;
set %W -er nPeaks;
sort -w %W %W_A;
};

if(nn>0)
{
win -a %F; // activate FFT wks
wks.addCol(Pki);
wks.addCol(Pkx);
wks.addCol(Pky);
copy %W_Pki %H_Pki;
copy %W_A %H_Pkx;
copy %W_B %H_Pky;
};

win -cd %W; // delete temporary wks

Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 10/23/2005 :  11:27:04 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Dean,

You need to save the graph's window name in a string variable and activate at the end. Looks like the FFT graph is created in the fourth code section which should therefore be changed to this...

worksheet -s 4 0 4 0;
worksheet -p 200 Origin;
%P=%H; // save graph name
layer1.y.from = 0;
layer1.x.from = 0;
layer1.x.to = 3E9;
layer1.y.to = 10;

Then you can restore the graph window with this command...

win -a %P; // activate FFT graph

Mike Buess
Origin WebRing Member
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