Add legend in roofit

Dear @couet

Thank you very much for your response. Here’s the solution. It might not be straight forward to guess the names of the PDFs.

TLegend *leg = new TLegend(0.57,0.73,0.78,0.93);
  leg->SetBorderSize(0);  // no border
  leg->SetFillStyle(0);
  leg->AddEntry("h_data","Data","pe");
  leg->AddEntry("pdf_Norm[deltaM_kspipi]","Total Fit","l");
  leg->AddEntry("pdf_Norm[deltaM_kspipi]_Comp[gauss]","Gaussian","l");
  leg->AddEntry("pdf_Norm[deltaM_kspipi]_Comp[johnson]","Johnson","l");
  leg->Draw();

Here’s what helped.

1 Like