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
 Forum for Origin C
 worksheet vs 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/21/2006 :  3:10:47 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hi all,

Is it posible to put column data into legend and how? In each worksheet I have a column with 6 row data that I would like to appear on graph as a legend but no idea how to do it

Thanks
oliver

Deanna

China
Posts

Posted - 09/21/2006 :  10:13:00 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Suppose the second column of the below worksheet has the legend texts


To use the texts for the legend like this:


The following code should work:


void test_legend()
{
GraphPage gp("Graph1");
if ( !gp.IsValid() ) return;

vector<string> vS;
Dataset ds("data2", 1);
ds.GetStringArray(vS, 0, 2);

gp.LT_execute("legend -s"); //Create a legend on the graph page

string str;
str.Format("legend.text$=\\l(1) %s\n\\l(2) %s\n\\l(3) %s", vS[0], vS[1], vS[2]);
gp.LT_execute(str);
}




Deanna
OriginLab GZ Office
Go to Top of Page

ovince

Yugoslavia
Posts

Posted - 09/22/2006 :  12:23:43 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello

Thank you. What if I already have one legend? In this form (bellow) the new legen just overwrite the old one. Is there a command option to append a new legend? This is the form:

LT_execute("legend -s;");
LT_execute("legend.text$='\l(1) all poins
\l(2) mean-no weight
\l(3) mean-weight
\l(4) median';");
LT_execute("legend.left=4500;");
LT_execute("legend.top=3100;");
LT_execute("legend.background = 1;");

legend with data number
gpg.LT_execute("legend -s");
string str;
str.Format("legend.text$= \\l(1)%s\n \l(2)%s\n \\l(3)%s\n \\l(4)%s\n \\l(5)%s\n \\l(6)%s\n \\l(7)%s", vS[0], vS[1], vS[2], vS[3], vS[4], vS[5], vS[6]);
gpg.LT_execute(str);


oliver

P.S. I also have a problem to implement the program makeLayout2.c that you sent via email. It reports some errors. Not clear why. I have replyed to that email with more detail. thanks
Go to Top of Page

Deanna

China
Posts

Posted - 09/22/2006 :  01:18:27 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
In this case, we can add a label instead. Please try the following code


void test_label()
{
GraphPage gp("Graph1");
if ( !gp.IsValid() ) return;

vector<string> vS;
Dataset ds("data2", 1);
ds.GetStringArray(vS, 0, 2);

string str;
str.Format("label \\l(1) %s\n\\l(2) %s\n\\l(3) %s", vS[0], vS[1], vS[2]);
gp.LT_execute(str);
}



I have checked tech@originlab.com for several times today. But I did not see your email. I have no idea what happens. Would you please send me the email again? Thank you.

Deanna
OriginLab GZ Office

Edited by - Deanna on 09/22/2006 01:19:13 AM
Go to Top of Page

ovince

Yugoslavia
Posts

Posted - 09/22/2006 :  01:51:10 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
hi,

Label is an object no? I was trying to positione it and make a nice border but does not work. This was the idea:

;string str;
;str.Format("label %s\n %s\n %s", vS[0], vS[1], vS[2], vS[3]);
;gpg.LT_execute("label.background = 1;");
;gpg.LT_execute("label.left=4500;");
;gpg.LT_execute("label.top=3100;");
;gpg.LT_execute(str);

(note that I have corrected \\l(1) %s\n\\l(2) %s\n\\l(3) %s to %s\n %s\n %s; could be this the reason; no I hope)

I have sent the email again. Should be there already. Thanks many...very happy for all helps

Oliver


Go to Top of Page

Deanna

China
Posts

Posted - 09/22/2006 :  02:17:56 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Yes, a label is an object. But its name is text.

I suggest that you change your code like:

str.Format("label %s\n%s\n%s\n%s", vS[0], vS[1], vS[2], vS[3]);
gp.LT_execute(str);
gp.LT_execute("text.background = 1;");
gp.LT_execute("text.left=4500;");
gp.LT_execute("text.top=3100;");



Note that there should be 4 '%s' if your want to put 4 strings into the str.

There is a very useful Labtalk command you might want to know. Active a graph page, and type
list -o
in the command window. The names of the objects on the active graph layer will be listed. :)

Deanna
OriginLab GZ Office
Go to Top of Page

ovince

Yugoslavia
Posts

Posted - 09/22/2006 :  02:39:52 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
hi,

new tricky problem. With your suggestion the title of the graph (grpName) is moved not the text that I would like. How to distinguish between two. This is the part of routine:

//set X and Y titles
LT_set_str("%P", grpName);
LT_execute("lab -p 45 2 -s %P;");
LT_execute("lab -xb (T);");
LT_execute("lab -yl (index);");
LT_execute("lab -r Legend;");
LT_execute("legend -s;");
LT_execute("legend.text$='\l(1) all poins
\l(2) mean-no weight
\l(3) mean-weight
\l(4) median';");
LT_execute("legend.left=4500;");
LT_execute("legend.top=3100;");
LT_execute("legend.background = 1;");

//legend with data number (Deanna)
vector<string> vS;
Dataset ds(wks, 8);
ds.GetStringArray(vS, 0, 6);


string str;
str.Format("label %s\n %s\n %s\n %s\n %s\n %s\n %s", vS[0], vS[1], vS[2], vS[3], vS[4], vS[5], vS[6]);
gpg.LT_execute(str);
gpg.LT_execute("text.background = 1;");
gpg.LT_execute("text.left=45;");
gpg.LT_execute("text.top=31;");


so the grpName is moved not the label

oliver
Go to Top of Page

Deanna

China
Posts

Posted - 09/22/2006 :  05:06:27 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
It seems that there are more than one labels in your graph. The label we have just created was named after text1, or something like that. The OC function does not use the correct name.

Let's first check the name of the label. We can do it as follows:
1. Select the label with the mouse;
2. In the script window, type:
select -g a;
%a=

This should output the name of the label.

With the correct name, you can modify your OC function, and it should be okay (I hope :P ).

Deanna
OriginLab GZ Office

Edited by - Deanna on 09/22/2006 05:07:38 AM

Edited by - Deanna on 09/22/2006 05:09:28 AM
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