# Stat box is not saved with TGraph

**URL:** <https://root-forum.cern.ch/t/stat-box-is-not-saved-with-tgraph/32745>\
**Category:** Newbie\
**Created:** [February 14, 2019, 5:48pm UTC](https://root-forum.cern.ch/t/stat-box-is-not-saved-with-tgraph/32745 "2019-02-14T17:48:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nyx](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/n/dc4da7/32.png) [@Nyx](https://root-forum.cern.ch/u/Nyx)\
**Post date:** [February 14, 2019, 5:48pm UTC](https://root-forum.cern.ch/t/stat-box-is-not-saved-with-tgraph/32745/1 "2019-02-14T17:48:58Z")

</div>

I am fitting several TGraph objects, and if the fit is not good, I want to save a plot of the TGraph, the fit function and the stat box.

On top of my macro I have the option

> gStyle-\>SetOptFit();

Once I defined my function and set parameters, I do

> gr-\>Fit(“f1”, “WMR”)  
> …  
> …  
> …  
> if(f1-\>GetChisquare\>0.1) gr-\>Write(name);

where “name” is a char variable defined before.

The TGraph object and the fit function are saved in the root file, but the stat box does not appear. How can I fix this?

---

<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:** [February 15, 2019, 8:35am UTC](https://root-forum.cern.ch/t/stat-box-is-not-saved-with-tgraph/32745/2 "2019-02-15T08:35:44Z")

</div>

Just before reopening the file do:

```auto
gStyle->SetOptFit(1);

```
