THStack statbox coloring not the same for Draw() and Draw("nostack")

Drawing a stacked or nostacked THStack results in different coloration for the same alpha and fill methods. It appears the last drawn box is the same alpha indicating the others are redrawn on top of themselves during stacking.
THStackTest.cpp (2.0 KB)


ROOT Version: 6.09/03
Platform: Ubuntu 16.04
Compiler: linuxx8664gcc


I am not sure I fully understand your question. I get the following plot when I execute your macro. What is wrong there ?

Please compare the plots when drawn with and without “nostack”
The fill alpha of the stat boxes does not match that of the histogram for the stacked version, the stat boxes are substantially darker, while in the nostacked version they are the same. The exception is the last drawn stat box, the yellow one which is the same alpha consistently. Also, note in the non-yellow boxes, the font appears wider, as if slightly misaligned when drawn multiple times.NoStack.pdf (18.3 KB)
Stack.pdf (19.2 KB)
Sorry this example program is rather difficult to see the coloration of the nostack histogram due to overlap. Is there a way to shift a FillRandom(“gaus”,10000) away from a mean=0 value?

Try:

((TF1*)(gROOT->GetFunction("gaus")))->SetParameters(10., 0.5, 0.1);
((TF1*)(gROOT->GetFunction("gaus")))->Draw();

which you may then use in your loop as:

((TF1*)(gROOT->GetFunction("gaus")))->SetParameters(1., -2. + a * 4. / (Nplots - 1.), 0.5);
Histos.at(a)->FillRandom("gaus",10000/(a+1));

Ok, much improved. Now it is clear from the two output plots that something odd is occurring with the statbox drawing.
NoStack.pdf (17.3 KB)
Stack.pdf (17.9 KB)
THStackTest.cpp (2.2 KB)

You mean that in case of no “nostack” option the stat boxes are too bright ?

Yes. But only the first 4. The last, yellow one, does not have this issue and looks the same in both plots. I think this stems from the stat boxes being redrawn somehow for the others leading to the inconsistent appearance. I can submit this as a bug on Jira if you agree this is not a coding issue on my side.

Yes your code looks fine. At least at a first glance.
Thanks for the Jira report.

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