Re: [ROOT] strange graph->Fit() behaviour

From: Rene Brun (Rene.Brun@cern.ch)
Date: Mon Nov 18 2002 - 15:47:51 MET


Hi,

Use DrawCopy instead of Draw if you want to save the original function.

Rene Brun

On Sun, 17 Nov 2002, payman hosseini wrote:

> hi
> i have function that graphs a bunch of lines and then fits them
> the first time i call this function, it works properly
> it draws the graph and draws the fit
> 
> the second time i call it(with new points to draw), it draws the
> points, but
> when it fits them, the fit function deletes everything under it
> it deletes the axix tic marks and the grid under it
> 
> this is very strange behaviour. am i doing something wrong?
> i am using MSVC++ under win2000
> thank you
> 
> here is the function
> 
> void draw_psychometric_function(TCanvas * psychometric_final,Int_t
> big_contrast_array_len,Float_t * psychometric_x,Float_t *
> psychometric_y,Float_t * psychometric_err,const char * file_title,Int_t
> msg)
> {
> 	psychometric_final->SetGrid();
> 	psychometric_final->SetTitle(file_title);
> 	TGraphErrors *gr1_1 = new TGraphErrors(big_contrast_array_len,
> psychometric_x, psychometric_y, 0, psychometric_err);
> 	gr1_1->ResetAttFill();
> 	gr1_1->Draw("AP*");
> 	gr1_1->SetMaximum(1);
> 	gr1_1->SetMinimum(0);
> 	
> 	gr1_1->SetTitle(file_title);
> 	gr1_1->GetXaxis()->SetTitle("Contrast");
> 	gr1_1->GetYaxis()->SetTitle("Probability of Coherent Judgment");
> 	gr1_1->GetXaxis()->CenterTitle();
> 	gr1_1->GetYaxis()->CenterTitle();
> 	
> 	TF1 *func = new TF1("fitf",fitf,-150,150,2);
> 	func->SetParameters(5,22);
> 	func->SetParNames("Mean_value","Sigma");
> 	gr1_1->Fit(func,"rem");//,"same");
> 
> 	//gr1_1->Draw("AP*");
> 
> 	psychometric_final->Update();
> 
> }
> 
> Paymon Hosseini
> 
> 



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:18 MET