SetStatFormat to change mean only in stats box

Hi ROOT team,

my question concerns the displayed mean in the stats box of a 1D histogram. I have two histograms displayed on 1 page. The two means are displayed by default as .001234 and 1.234
It seems to display 4 decimal places of accuracy. I’d like to turn that down to 2.

I used:


This displays the first mean as .0012, but the other stats box fields (overflow, underflow) now become: xx.0000, and the second mean becomes 1.2345. If I use a second SetStatFormat command before plotting the second histogram, it seems to go back and change the format on the first histogram.

Is there a way to set just the mean on a histogram by histogram basis?
many thanks

Try (note -> “gStyle” is a “global” which points to the “current style”):
gStyle->SetStatFormat(“6.2g”); // maximum 2 significant digits

Note also -> once you draw something and its “stats” box appears (“gPad->Modified(); gPad->Update();” is mandatory), you can change its appearance using the methods of the TPaveStats class (so you can change each “stats” box individually).

Hi, thanks, that gets me close.

My mean prints out as .0012 as desired, however the overflow went from 220 to 2.2e+02. This is for a publications so I’m bleeding on this.

I see I can do “6.3g” and get .00123 and 220 to display, that would be better than nothing.