# Trouble Displaying fit statistics

**URL:** <https://root-forum.cern.ch/t/trouble-displaying-fit-statistics/40562>\
**Category:** Newbie\
**Created:** [July 22, 2020, 12:20am UTC](https://root-forum.cern.ch/t/trouble-displaying-fit-statistics/40562 "2020-07-22T00:20:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Edward\_Finkelstein](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/edward_finkelstein/32/20070_2.png) [@Edward\_Finkelstein](https://root-forum.cern.ch/u/Edward_Finkelstein)\
**Post date:** [July 22, 2020, 12:20am UTC](https://root-forum.cern.ch/t/trouble-displaying-fit-statistics/40562/1 "2020-07-22T00:20:16Z")

</div>

Hello,  
I am trying to display the fit statistics for a fitted graph using `gStyle->SetOptFit(1111);`, but for some reason, the fit stats are not displaying on the graph.  
[test.cxx](https://root-forum.cern.ch/uploads/short-url/bYXV0xBjd0evJWXvp9k4pWiFxve.cxx) (1.5 KB)  
[data.txt](https://root-forum.cern.ch/uploads/short-url/fT5BSKBYp4ly2u9Bdf0x2FOdpb8.txt) (59 Bytes)  
_ROOT Version:_ 6.23

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [July 22, 2020, 9:32am UTC](https://root-forum.cern.ch/t/trouble-displaying-fit-statistics/40562/2 "2020-07-22T09:32:03Z")

</div>

```auto
void test(){
   gStyle->SetOptFit(1111);
   auto c = new TCanvas();
   c->SetGrid();

   auto graph = new TGraphErrors("./data.txt","%lg %lg %lg %lg");
   graph->SetMarkerStyle(kCircle);
   graph->SetFillColor(0);
   graph->SetTitle("Test");
   graph->Draw("PEA");

   auto g = new TF1("Quadratic Fit","[0]+[1]*x+[2]*x**2",0.,10.);
   g->Print();
   g->SetParameters(0,0,1);
   g->SetLineColor(kRed);

   graph->Fit(g,"M","",0.,10.);
   graph->Print();

   auto leg = new TLegend(.1,.7,.3,.9,"Test");
   leg->SetFillColor(0);
   leg->AddEntry(graph,"Measured Points");
   leg->AddEntry(g,"Fit");
   leg->Draw();

   auto text = new TLatex(4.,5.,"f(x)=p_{0}+p_{1}x+p_{2}x^{2}");
   text->Draw();

   gPad->Update();
   TPaveStats *ps = (TPaveStats*)graph->GetListOfFunctions()->FindObject("stats");
   ps->SetX1NDC(0.35);
   ps->SetX2NDC(0.6);
   ps->SetY1NDC(0.55);
   ps->SetY2NDC(0.8);
   gPad->Modified();
   gPad->Update();
}

```

 ![Screenshot 2020-07-22 at 11.31.34](https://root-forum.cern.ch/uploads/default/original/3X/4/9/491a87765c7611eec97daf0feaf4748195b7d4be.jpeg)

---

<div class="post-metadata">

**Author:** ![Edward\_Finkelstein](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/edward_finkelstein/32/20070_2.png) [@Edward\_Finkelstein](https://root-forum.cern.ch/u/Edward_Finkelstein)\
**Post date:** [July 23, 2020, 1:39am UTC](https://root-forum.cern.ch/t/trouble-displaying-fit-statistics/40562/3 "2020-07-23T01:39:27Z")

</div>

Thank you very much!
