Try this instead:
void fit()
{
TCanvas *c1 = new TCanvas("c1","c1",700,500);
Int_t n = 20;
// mu_Errm
Double_t x[20] = {0.002723, 0.003313, 0.003625, 0.003854, 0.004033, 0.004178, 0.004296, 0.004406, 0.00451, 0.004618, 0.004739, 0.0048
73, 0.005035, 0.005227, 0.005451, 0.005723, 0.006051, 0.006504, 0.007195, 0.008657 };
Double_t ex[20] = {7.95421e-06, 3.22325e-06, 2.15406e-06, 1.68393e-06, 1.34469e-06, 1.06632e-06, 9.06832e-07, 8.99227e-07, 8.64925e-0
7, 9.82474e-07, 1.02539e-06, 1.21688e-06, 1.44946e-06, 1.70204e-06, 2.06965e-06, 2.45717e-06, 3.07269e-06, 4.33906e-06, 7.71312e-06, 2.
26849e-05};
Double_t y[20] = {0.13327, 0.13322, 0.13272, 0.13311, 0.13293, 0.13309, 0.13317, 0.13351, 0.13400, 0.13389, 0.13408, 0.13392, 0.13408
, 0.13403, 0.13376, 0.13387, 0.13390, 0.13415, 0.13414, 0.13502};
Double_t ey[20] ={0.00016, 0.00015, 0.00016, 0.00016, 0.00016, 0.00016, 0.00014, 0.00016, 0.00016, 0.00015, 0.00016, 0.00016, 0.00017
, 0.00017, 0.00018, 0.00019, 0.00019, 0.00020, 0.00023, 0.00023};
// TGraph
TGraph *gr1 = new TGraphErrors(n,x,y,ex,ey);
gr1->SetMarkerStyle(20);
gr1->SetMarkerColor(kBlue);
gr1->SetDrawOption("P");
gr1->SetLineColor(4);
gr1->SetLineWidth(2);
gr1->GetXaxis()->SetRangeUser(0,0.015);
gr1->GetYaxis()->SetRangeUser(0.130,0.137);
gr1->GetXaxis()->SetTitle("pi0_ErrM");
gr1->GetYaxis()->SetTitle("#mu of pi0_M_prefit");
gr1->GetXaxis()->CenterTitle();
gr1->GetYaxis()->CenterTitle();
gr1->GetXaxis()->SetTitleSize(0.05);
gr1->GetYaxis()->SetTitleSize(0.04);
// Range wise fit
gr1->Sort(); // make sure points are in the "increasing order in x"
Double_t par[7];
// 0 to 0.004
Double_t xmin1 = 0, xmax1 = 0.0041;
TF1 *f1 = new TF1("f1","pol1", xmin1, xmax1);
// 0.004 to 0.0055
Double_t xmin2 = 0.0041, xmax2 = 0.0055;
TF1 *f2 = new TF1("f2","pol2", xmin2, xmax2);
// 0.0055 to 0.015
Double_t xmin3 = 0.0055, xmax3 = 0.015;
TF1 *f3 = new TF1("f3","pol1", xmin3, xmax3);
TF1 *total = new TF1("total","pol1(0)+pol2(2)+pol1(5)",0,0.015);
gr1->Fit("f1", "R");
gr1->Fit("f2", "R+");
gr1->Fit("f3", "R+");
f1->GetParameters(&par[0]);
f2->GetParameters(&par[2]);
f3->GetParameters(&par[5]);
total->SetParameters(par);
// gr1->Fit("total","R+");
gr1->Draw("AP");
c1->Update();
//c1->GetFrame()->SetFillColor(21);
c1->GetFrame()->SetBorderSize(12);
c1->Modified();
}
It gives me this: