Stat box is not saved with TGraph

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


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?

Just before reopening the file do: