I create several histograms in a loop, leaving the default statistics style for most histograms (i.e. I do not call gStyle->SetOptStat()).
In an if clause, I check for a specific histogram for which I would like to set a specific style. For this, I have
However, this does not have any effect. Still, the default style is used.
To achieve what I want, I can do
However, I do not understand why the first call does not work, and how to use it correctly.
You can act directly on an individual histogram:
That’s actually what I did. hMap is a map of TH2F* (I forgot to mention that), so hMap[id]->SetStats() is acting directly on the histogram.
should work … does it ?
No, it does not. It shows the name, the number of entries, the mean and RMS, but not over-/underflows and the integral. However, it compiles without complaining.
I am sure I am calling it for the right object as SetXTitle() on the same object works fine.
It is a 2-d histogram, but I think this is not important.
sorry I was wrong.
You should do
TH2D *h = new TH2D("h","h",20,-4,4,20,-4,4);
TPaveStats *ps = (TPaveStats*)h->GetListOfFunctions()->FindObject("stats");
Thank you, that works fine now (though only integers seems to be allowed as style arguments then; things like “e” don’t work.)
Also, I still do not understand how to use h->SetStats(). But anyway, thanks!
h->SetStats() takes a boolean and switches the statistics box on or off. It’s not to change the styling.