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
 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 - 10/29/2006 :  05:10:16 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
hi

I am trying to make a legend using data from the output file (10 numbers in it). First I plot like this:

===========================================
int k = gly.AddPlot( crv, IDM_PLOT_SCATTER );
DataPlot dpLine = gly.DataPlots(k);
dpLine.Curve.Symbol.Type.nVal = 3;
===========================================



Thereafter I make a Legend like this



============================================
FILE *stream;
stream = fopen( name_path, "r" );

string head, sLegend, tmps;
head = "\g(t)\-(B)\+(c) / \g(t)\-(B)\+(l):";
sLegend=head;
for (m=0; m<10; m++)
{
fscanf( stream,"%s\n", cTmp);
string ts(cTmp, 5);
//fscanf( stream,"%s\n", tmps);
//string ts = tmps.Left(5);
printf("%s\n", ts);
sLegend.Format("%s\n\l(%d) %s",sLegend,m+1,ts);
}
fclose( stream );

gly.LT_execute("legend"); // create legend
GraphObject goLegend = gly.GraphObjects("legend");
if( goLegend.IsValid() ) goLegend.Text = sLegend;
=======================================================


I obtain this figure





What is the reason that the decimal numbers are not indexed with 1, 2 .... 10 in the Legend? Interestingly, this works fine if I use


dpLine.Curve.Line.Color.nVal = k;

where k runs from 1 to 10 in the for loop

What I do wrong?

thanks
oliver

Deanna

China
Posts

Posted - 10/29/2006 :  9:05:42 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I think the reason is that the graph layer has only one data plot. If this is true, the easiest solution is to change this line:
sLegend.Format("%s\n\l(%d) %s",sLegend,m+1,ts);
to:
sLegend.Format("%s\n\%d %s",sLegend,m+1,ts);


Deanna
OriginLab Technical Services
Go to Top of Page

ovince

Yugoslavia
Posts

Posted - 10/29/2006 :  10:50:06 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
thank you Deanna,

I made this change

string head, sLegend, tmps;
head = "\g(t)\-(B)\+(c) / \g(t)\-(B)\+(l):";
sLegend=head;
for (m=0; m<10; m++)
{
fscanf( stream,"%s\n", cTmp);
string ts(cTmp, 5);
sLegend.Format("%s\n\%d:\t %s",sLegend,m+1,ts);
}
fclose( stream );


I get somthing like this which I hardly understand why





I affect every second Legend label. Why is that?

Oliver
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 10/30/2006 :  12:28:04 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Oliver,

Removing the extra '\' in front of %d will fix it... sLegend.Format("%s\n%d:\t%s",sLegend,m+1,ts);

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