Bug in THStack: SetBinLabel works on X but not on Y axis?

Dear all,

I would like to change the bin labels of the X and Y axes in a THStack. I change the labels of the first TH2 added to the stack. It works for the X axis but not for the Y. Moreover, if I draw the first histo in a canvas, the bin on the Y axis is set but not on the X axis (see snapshot and the attached macro).

I might be doing something wrong, however I believe that if
h1->GetXaxis()->SetBinLabel(1, “new”);
works then
h2->GetYaxis()->SetBinLabel(1, “new”);
should work as well.

Thank you in advance for your help.
Barth



multicolor.C (1.61 KB)

You must set the stack attributes, not the first histogram. See the lines modified

Rene

[code] hs->Draw(“lego1”);
hs->GetXaxis()->LabelsOption(“v”);
hs->GetYaxis()->LabelsOption(“v”);
hs->GetXaxis()->SetLabelSize(0.03);
hs->GetYaxis()->SetLabelSize(0.03);

hs->GetXaxis()->SetBinLabel(1, “new”);
hs->GetYaxis()->SetBinLabel(5, “new51”);
// attempt 1
h2->GetYaxis()->SetBinLabel(1, “new”);
// attempt 2 (who knows…)
h2->GetYaxis()->SetBinLabel(5, “new5”);
[/code]

Thank you very much