Hi experts,
I’m having some trouble getting the desired result trying to set the range of the vertical axis when drawing a THStack. Take this code for example (running this in ROOT 5.34):
[code]{
TH1D *hist = new TH1D(“hist”, “”, 2, 0, 1);
TH1D *hist2 = new TH1D(“hist2”, “”, 2, 0, 1);
hist->SetBinContent(1, .25);
hist->SetBinContent(2, .75);
hist->SetFillColor(kBlue);
hist2->SetBinContent(1, .75);
hist2->SetBinContent(2, .25);
hist2->SetFillColor(kRed);
THStack *stack = new THStack(“stack”, “stack”);
stack->Add(hist);
stack->Add(hist2);
stack->Draw();
stack->SetMaximum(1);
gPad->Modified();
}[/code]
I would like the range of the vertical axis to be exactly 0 - 1, but I get a maximum slightly larger than 1 (and if I say SetMaximum(0.8 ) I get something around 0.9). I also tried stack->GetYaxis()->SetRangeUser(0, 1), but that didn’t work either. What does work is to interactively zoom the vertical axis, then right click it and select SetRangeUser, enter 0 and 1, and I get what I want. Any idea what I need to do to achieve this in my script without manual intervention?
Thanks in advance for your help!