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
 axis title
 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 - 07/04/2006 :  06:26:18 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
hi All

I would like to ask for help. The problem is trivial seems to me but I can not find the solution :(


I have about 50 files with nice 'scientific' names like:

LickCN1.dat
LickFe5270.dat
etc.

I wrote a small routine in Origin C which reads in the content of these files and plot an appropriate
plots. What I would like to do is to label Y axis of these plots with the name of the files (LickCN1,
LickFe5270 etc.). The routin is somthing like this (it is short so I will not hesitate to copy-paste it):

void plotting_with_err_bar()
{

PageBase pg;

// Create a Project object
Project proj;

// Loop over all pages in the project and display their names:
foreach (pg in proj.Pages)
{
String name = pg.GetName();


// Declare worksheet, data curve and error dataset and check validity
Worksheet wks(name);
Curve crvData(wks, 0, 1);
Dataset dsErr(wks, 2);


// Create a new graph and plot the data as a scatter plot
GraphPage gpg;
gpg.Create( "Origin.OTP" );
GraphLayer gly = gpg.Layers( 0 );
gly.AddPlot( crvData, IDM_PLOT_SCATTER );


// Add the error dataset as error bar to this plot
int nPlotIndex = gly.AddErrBar( crvData, dsErr );


// Rescale layer
gly.Rescale();


//set X and Y titles
LT_execute("lab -xb (classes);");
LT_set_str("%P", name);
LT_execute("label -yl %P;");

}
}



I have tryed with lots of combinations like:
//"lab -yl $(P);";
//"lab -yl P;";
//"lab -yl $(%P);";
//"lab -yl %P;";
//"lab -yl (P);";
//"lab -yl (%P);";
//"label -yl %P;";
//"lab -yl ($(%P));";

but no success.


Could someone to help me with this?

Thanks
oliver

Deanna

China
Posts

Posted - 07/04/2006 :  11:34:29 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi, Oliver.

I see there are two problems. First, it will cause dead loop; Second, it failed to add labels to y axis.

Therefore, I modified your code like this:


void plotting_with_err_bar()
{

// Create a Project object
Project proj;
PageBase pg;


// Loop over all pages in the project and display their names:
foreach (pg in proj.Pages)
{
string name = pg.GetName();

// Declare worksheet, data curve and error dataset and check validity
Worksheet wks(name);

if (!wks) continue; //Added to avode dead loop

Curve crvData(wks, 0, 1);
Dataset dsErr(wks, 2);

// Create a new graph and plot the data as a scatter plot
GraphPage gpg;
gpg.Create( "Origin.OTP" );
GraphLayer gly = gpg.Layers( 0 );
gly.AddPlot( crvData, IDM_PLOT_SCATTER );

// Add the error dataset as error bar to this plot
int nPlotIndex = gly.AddErrBar( crvData, dsErr );

// Rescale layer
gly.Rescale();

//set X and Y titles
LT_execute("lab -xb (classes);");


//Deleted
//LT_set_str("%P", name);
//LT_execute("label -yl %P;");



//Added
string str = "label -yl ";
str+=name;
str+=";";
LT_execute(str);


}
}




I hope this will help ^_^.

Deanna
OriginLab GZ Office
Go to Top of Page

larry_lan

China
Posts

Posted - 07/04/2006 :  11:41:01 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Oliver:

In your case, LT_execute should associate with a particular layer, like:


void test()
{
GraphPage page("Graph1");
GraphLayer lay = page.Layers(0);
lay.LT_execute("lab -xb (classes)");
}


Larry
OriginLab GZ Office
Go to Top of Page

ovince

Yugoslavia
Posts

Posted - 07/06/2006 :  06:06:57 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
hello


Thanks many for help

Regards
oliver
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