Problem in setting Y axis range for THStack

Dear all,

I’m working with ROOT 5.34/30. I have a plot which is made of some histograms by THStack. I’m trying to change axis range by this piece of code :

TCanvas c1;
hsb->Draw();
hsb->GetXaxis()->SetRangeUser(4, 400);
hsb->GetYaxis()->SetRangeUser(0, 9);

The X axis range changes properly, but Y axis range DOESN’T CHANGE. I also tried this :

hsb->GetYaxis()->SetLimits(0, 9);

But still no change in Y axis range. Being disappointed, I had to use this method :

hsb->SetMaximum(9);

This WORKS. But still I have a question that why SetRangeUser & SetLimits methods don’t work.

Any help will be highly appreciated.

Thanks in advance

Yes, for the axis supporting the content of the histograms (Y axis for 1D histograms and Z axis for 2D) SetMinimum and SetMaximum should be use. The axis holding the contents does not have a range but a minimum and maximum value which can evolve according to the filling operations you are doing.

Ah yes. Thanks a lot for your help.