Displaying opt Fit numbers for two histograms

Hello,

I am trying to show the Fit statistics for two gausian histograms that i’m plotting on the same canvas (basically its a ‘before and after’ image)

So far i can only get the Fit statistics for the first plot (c0) to show up. Everything else looks fine, but i can’t get the Fit statistics for the second plot (u0) to appear anywhere. Ideally i’d like the secound statistic to appear below the first.

the relevant code i’m using is

gStyle->SetOptFit(1111);
 TF1 *f2 = new TF1("f2","gaus",-.1,.1);
  c0->Fit("f2","R");
  u0->Fit("f2","R");
  c0->Draw("Hist");
  u0->Draw("Same Hist");

use option “SAMES” instead of “SAME”

Thanks, that works!

Is there some way in the code to move the secound stat box down automatically? Currently i have to drag the second stat box to a new location by hand. I’ve tried SetStatW/X/Y but that moves both boxes.

see section “Statistics Display” at root.cern.ch/root/html/THistPainter.html#HP07

Rene

Following the ‘statistics Display’ section i added what i understand to be the appropriate commands, but i get an error.

c0->Draw("Hist");
  gStyle->SetStatW(.19);

  u0->Draw("SAMES Hist");

  TPaveStats *st = (TPaveStats*)u0->FindObject("stats");
  st->SetX1NDC(0.5);
  st->SetX2NDC(0);

the error reads:
Error: illegal pointer to class object st 0x0 751 note/note_deltaPhi.C:46:
*** Interpreter error recovered ***

where line 46 is ‘st->SetX1NDC(0.5);’ which i copied exactly from the ‘statistics Display’, save for the value 0.5

after u0->Draw(), you must call canvas->Update() to force the generation of the TPaveStats object.

Rene