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
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 Plotting Fit data

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
Kaemme1909 Posted - 06/18/2013 : 05:40:37 AM
Origin Ver. and Service Release (Select Help-->About Origin): 9
Operating System: Win7

Hi together,

I like to plot my data from a fit to the plot from the original data. This is my code:
void PlotFitXY(int NUMB)
{
for(int i=1;i<=NUMB;i++)
{
WorksheetPage WSP= Project.WorksheetPages.Item(i);
Worksheet ws = WSP.Layers(0);
set_active_layer(ws);
LT_execute("plotxy iy:=(1,2) plot:=200");
bool bInit;
Operation& op = (Operation&)op_create("FitNL", bInit); // the operation name of NLFit is FitNL
if( !bInit )
{
out_str("Error in op create");
return;
}

Tree trOp;
op.GetTree(trOp);


if( !ws )
return;
DataRange dr;
dr.Add(ws, 0, "X");
dr.Add(ws, 1, "Y");

// init trOp.GUI.InputData treenodes from dr and do SetData, SetFunction actions
string strFunction = "ExpDec3";
string strCategory = "Exponential";
if (OP_NOERROR != op.OnInitDataFromOCLT(trOp, trOp.GUI.InputData, dr, strFunction, strCategory) )
{
out_str("Fail to init data from data range");
return;
}
op.SetTree(trOp);// set the changes of trOp back to op object

int nAutoUpdate = AU_AUTO;
op.OnNoEdit(0, nAutoUpdate);

op.Execute(); // do fit and genereate report
Worksheet wsp = WSP.Layers(2);
set_active_layer(wsp);
LT_execute("plotxy iy:=(1,2) plot:200");

}
}

The first plot and the fit is working, but I do not get the fit data plotted to the original graph.

Thanks for your help.

2   L A T E S T    R E P L I E S    (Newest First)
Kaemme1909 Posted - 06/21/2013 : 06:32:42 AM
Thanks for your help. Works fine.
Penn Posted - 06/18/2013 : 11:06:13 PM
Hi,

Two issues:
1. The plotxy X-Function will create a new graph by default. If you want to get the fitted data plotted to the original graph, you have to specify the target graph to plot the fitted data.
2. There is a syntax mistake in this line, "=" is missing.

LT_execute("plotxy iy:=(1,2) plot:200");

I change your code like below, and it is able to plot the fitted data to the original graph.

void PlotFitXY(int NUMB)
{
	for(int i=1;i<=NUMB;i++)
	{
		WorksheetPage WSP= Project.WorksheetPages.Item(i);
		Worksheet ws = WSP.Layers(0);
		set_active_layer(ws);
		LT_execute("plotxy iy:=(1,2) plot:=200");
		
		// Get the graph
		GraphPage gp = Project.ActiveLayer().GetPage();
		if(!gp)
			return;
		
		bool bInit;
		Operation& op = (Operation&)op_create("FitNL", bInit); // the operation name of NLFit is FitNL
		if( !bInit )
		{
			out_str("Error in op create");
			return;
		}

		Tree trOp;
		op.GetTree(trOp); 


		if( !ws )
			return; 
		DataRange dr;
		dr.Add(ws, 0, "X");
		dr.Add(ws, 1, "Y");

		// init trOp.GUI.InputData treenodes from dr and do SetData, SetFunction actions
		string strFunction = "ExpDec3";
		string strCategory = "Exponential";
		if (OP_NOERROR != op.OnInitDataFromOCLT(trOp, trOp.GUI.InputData, dr, strFunction, strCategory) )
		{
			out_str("Fail to init data from data range");
			return;
		}
		op.SetTree(trOp);// set the changes of trOp back to op object

		int nAutoUpdate = AU_AUTO;
		op.OnNoEdit(0, nAutoUpdate);

		op.Execute(); // do fit and genereate report
		Worksheet wsp = WSP.Layers(2);
		set_active_layer(wsp);
		
		// Correct the syntax issue, and specify where to plot the fitted data
		LT_execute("plotxy iy:=(1,2) plot:=200 ogl:=[" + gp.GetName() + "]1!");

	}
}


Penn

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000