I am trying to fit a TGraph2D to a TF2 function and then plot the TGraph2D, the TF2, and the fit statistics box with the fit parameters. The first two work fine, but the fit statistics do not seem to appear. Below is a test code that makes a TGraph2D, populates it with points that randomly deviate from a plane and then fits and plots it.
void test2D() {
TGraph2D *test = new TGraph2D();
TRandom *myRandom = new TRandom();
const float xMax = 10.0;
const float yMax = 5.0;
const float a = 2.0;
const float b = 4.0;
const float delta = 0.1;
const int nPts = 100;
gStyle->SetOptFit(1111);
//fill TGrahp2D
for (int i = 0; i < nPts; i++) {
float x = xMax * myRandom->Rndm();
float y = yMax * myRandom->Rndm();
float z = a * x + b * y + delta * myRandom->Rndm();
test->SetPoint(test->GetN(), x, y, z);
}
TF2 *pln = new TF2("pln", "[0] + [1]*x + [2]*y", 0.0, xMax, 0.0, yMax);
test->Fit("pln");
test->Draw();
gPad->Update();
pln->Draw("sames surf");
return;
}
Below is my output.
What do I need to add to get the fit statistics to show up?
Thanks,
Paul
ROOT Version: 6.20.00
Platform: Mac OSX 10.14.6
Compiler: Not Provided