Fitting TGraphErrors

Hi

I want to do a linear fit on a TGraphErrors. Attached is the plot I have so far. I want to get rid of the line connecting my datapoints, and instead draw a straight line of best fit though my points.

I have made many attempts but I cant seem to find the correct method. Below is the code that makes the attached plot where l, bb,aa,bbE and aaE are predefined. Does anyone know of any tutorials or how to’s to help me with this linear fitting?

Thanks.

TGraphErrors *gr1 = new TGraphErrors (l, bb, aa, bbE, aaE);
gr1->SetTitle(“Temperature profile along loop”);
gr1->GetXaxis()->SetTitle(“Module”);
gr1->GetYaxis()->SetTitle(“Average Module Temperature C”);
TCanvas c1 = new TCanvas(“c1”,“Tprofile”,100,20,800,400);
c1->SetBorderMode(0);
gr1->SetMarkerColor(2);
gr1->SetMarkerSize(1);
gr1->SetMarkerStyle(21);
gr1->Draw("AC
");


Hi,

you should be able to do gr1->Draw(“A*”); gr1->Fit(“pol0”).

Cheers, Axel.

Thanks

just for the record I finally got the fit with

TGraphErrors *gr1 = new TGraphErrors (l, bb, aa, bbE, aaE);
TF1 fit1 = new TF1(“fit1”,“pol1”, 0, 48);
//where 0 = x-axis_lowest and 48 = x_axis_highest
gr1->Fit(fit1, “R”);
gr1->Draw("A
");