Fit Statistics Box on TGraph2D

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

Hi,

@couet will be off his week, but when he’s back he will be able to answer how to make the fit statistics show up.

It looks like this is not implemented for TGraph2D

A much simpler answer than I was expecting. I’m glad that, at least I was not missing anything. I will write a routine to write the fit parameters manually then.

Thanks,

Paul

You may also issue a Jira report so we can try to add it in future versions.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.