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
 create legend
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

ovince

Yugoslavia
Posts

Posted - 09/17/2006 :  4:52:38 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hi All,

I have 3 plots on the graph and I would like to make a legend with message that explains what is what. Could somebody direct me how to do it

Thanks
Oliver

Deanna

China
Posts

Posted - 09/17/2006 :  10:09:11 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
How about this:


//Create a legend for all plots
legend -s;

//Set the legend text
legend.text$="\l(1) description for plot 1
\l(2) description for plot 2
\l(3) description for plot 3";


Deanna
OriginLab GZ Office
Go to Top of Page

ovince

Yugoslavia
Posts

Posted - 09/18/2006 :  12:59:12 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
hello,

thanks.

Are the options for legend described somewhere in Origin's help? I tryed to find with Search but no success.

I would like to positione the legend and create a border. How to do it?

oliver
Go to Top of Page

larry_lan

China
Posts

Posted - 09/18/2006 :  01:37:19 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Oliver:

The help file didn't list all of the object properties, however, you can type

legend.=

in the command window to show the properties for legend object. So to position the legend and add border, try the following scripts:

legend.x = value of x coordinates
legend.y = value of y coordinates
legend.background = 1; // Add border

Larry
OriginLab GZ Office
Go to Top of Page

ovince

Yugoslavia
Posts

Posted - 09/18/2006 :  01:56:43 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks Deanna and Larry.
Go to Top of Page

AMHumphries

UK
Posts

Posted - 09/20/2006 :  03:23:55 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I'm working on a legend myself, however I am trying to use data from a worksheet to insert into the legend (each worksheet processed has a metadata tag on it). The number of worksheets are variable, and so it has proved rather difficult. So far I am doing something along these lines:


loop (jj, 1, fileCount)
{
%J = Sheet($jj)_J;
%K = %J\l;
}


...(and further down)...


// create the legend
legend -s;
legend.text$ = %K;
legend.background = 1; // add a border



Which obviously does not work. I am finding it difficult to get to grips with the way Origin manipulates strings. Is there a way of doing this that works so that it remains in the same format and there are not too many changes to the rest of the script?

Go to Top of Page

larry_lan

China
Posts

Posted - 09/20/2006 :  04:53:30 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Andrew:

The syntax to specify a legend that includes data sets from a layer is:

\L(LayerNumber.DataPlotNumber,DataPointNumber) DataPlotName

For Example:

\L(1) Data1_B

means the first dataset of the current layer, and name it Data1_B. So may be you can change your scripts as:

loop (jj, 1, fileCount)
{
%J = Sheet$(jj)_J; // Note that $() is used for numeric to string conversion;
%K = "\L($(jj)) %J"; // Need to quote the string because there is space between \L($(jj)) and %J;
}
.....
// Create the legend
legend -s;
legend.text$ = %K;
legend.background = 1;


Larry
OriginLab GZ Office

Edited by - larry_lan on 09/20/2006 04:55:58 AM
Go to Top of Page

AMHumphries

UK
Posts

Posted - 09/20/2006 :  09:10:00 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks for the reply Larry, however when using the code that you provided me instead of getting "1239123_JUL_04_2006_10_20_39" which is an example of the meta-data, I simply get "Sheet1_J" on the legend.

Go to Top of Page

AMHumphries

UK
Posts

Posted - 09/20/2006 :  11:38:50 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Oh and the code you gave me is also over-writing the contents of %K on each pass so that instead of having several legend metadata tags, I have only one... the last one processed.

Go to Top of Page

AMHumphries

UK
Posts

Posted - 09/21/2006 :  11:41:32 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Bump.

Does anyone have any idea why this is happening?

Is it not possible to append to a variable in Origin?

Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 09/21/2006 :  3:10:42 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Oliver,

quote:
Does anyone have any idea why this is happening?
%K is overwritten by the line %K = "\L($(jj)) %J". If you want to append to previous %K try this...

%Z="";
loop (jj, 1, fileCount)
{
%J = Sheet$(jj)_J; // Note that $() is used for numeric to string conversion;
%K = "\L($(jj)) %J"; // Need to quote the string because there is space between \L($(jj)) and %J;
if(jj==1) %Z=%K;
else {
%Z=%Z
%K;
};
};
.....
// Create the legend
legend -s;
legend.text$ = %Z;
legend.background = 1;

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 09/21/2006 3:13:58 PM
Go to Top of Page

AMHumphries

UK
Posts

Posted - 09/25/2006 :  06:58:39 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I am still getting Sheet1_J (Sheet2_J, Sheet3_J, etc.) instead of the contents of Sheet1's J column cell 1 (Sheet2's, Sheet3's, etc.).
Should I be quoting %K = Sheet$(jj)_J; in any particular way? The data is alphanumeric if that helps. Probably with underscores too. Is %K able to manipulate non-numeric data like this?

Also the legend formatting leaves preceding tabs for each new line, is there a way to control this formatting?


Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 09/25/2006 :  08:03:47 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Sorry, but this is the first time you've indicated that you want the contents of a cell rather than the column name. Use this...

%J=Sheet$(jj)_J[1]$;

Each new line will start with a plot symbol rather than a tab. If you don't wan't a space between plot symbol and the next letter just remove the space between \L($(jj)) and %J...

%K = "\L($(jj))%J";

...If you don't want a plot symbol just use %K=%J.

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 09/25/2006 08:18:55 AM
Go to Top of Page

SvenP

29 Posts

Posted - 08/23/2010 :  05:04:19 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
Originally posted by larry_lan



The help file didn't list all of the object properties, however, you can type

legend.=

in the command window to show the properties for legend object.

Hmm...nothing happens.
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