Fitting two curves on same canvas


Please read tips for efficient and successful posting and posting code

ROOT Version: 6.18
Platform: Not Provided
Compiler: Not Provided


Good day

I am trying to fit two curves on the same canvas so I use the following, on the attached code:

{
  TGraphErrors *p = new TGraphErrors("PRD_gate244_2020.dat", "%lg %lg %lg"); 
  //TGraphErrors *p1 = new TGraphErrors("Timewalk_reversegate.txt", "%lg %lg %lg");
  TGraphErrors *p1 = new TGraphErrors("PRD_gate344_2020.dat", "%lg %lg %lg");
  TF1 *fit = new TF1("fit", "[0]/sqrt([1]+x) + [2]*x + [3]", 0., 1600.);
  fit->SetLineColor(kRed);
 fit->SetParameters(0.5, 1.0, 7.0, 7.0);
 //fit->SetParameters(75.0,82,83,83);
  //p->Fit(fit, "");
 // p->SetName("Stopbranch");
  p->SetTitle("Startbranch"); 
  p->Draw();
  fit->SetLineColor(kGreen);
  fit->SetParameters(75.0,82,83,83);
  p1->SetName("Startbranch");
  p1->Fit(fit, "");
  p1->Draw("same");

}

}

This just plots one data set and omits the second please help.

Fit_PRD2020.C (1.3 KB)PRD_gate344_2020.txt (115 Bytes) PRD_gate244_2020.txt (100 Bytes)

Add this line:

  p->GetHistogram()->SetMinimum(0);

just after p->Draw();

That works.Thanks very much!!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.