// http://root.cern.ch/root/html/TStyle.html#TStyle:SetOptStat
gStyle->SetOptStat(1111);
// ...
// http://root.cern.ch/root/html/TH1.html#TH1:SetStats
// SomeHisto->SetStats(kTRUE);
// ...
// http://root.cern.ch/root/html/THistPainter.html
SomeHisto->Draw("SAMES"); // you MUST draw "SomeHisto" first (e.g. with "SAMES")
gPad->Modified(); gPad->Update(); // make sure it's really (re)drawn
// http://root.cern.ch/root/html/TPaveStats.html
#if 1 /* 0 or 1 */
TPaveStats *s = ((TPaveStats*)(SomeHisto->FindObject("stats")));
// if (s) s->SetName("SomeDistinctObjectName"); // you can rename "stats" if you want
#else /* 0 or 1 */
TPaveStats *s = ((TPaveStats*)(gPad->GetPrimitive("stats")));
if (s) s->SetName("SomeDistinctObjectName"); // you MUST rename "stats"
#endif /* 0 or 1 */
if (s) {
s->SetTextColor(SomeColorIndex);
s->SetX1NDC(LeftX);
s->SetX2NDC(RightX);
s->SetY1NDC(BottomY);
s->SetY2NDC(TopY);
}
gPad->Modified(); gPad->Update(); // make sure it's really (re)drawn
1 Like