====== Set Display Range of Axis ======
The normal way to change the display range of an axis is:
histogram->GetYaxis()->SetRangeUser(lower,upper);
but there are several situations where this fails. See below for help in these cases.
===== Y Axis of a normalized Histogram =====
Assume you have a histogram which has been normalized it with
hist->SetNormFactor(1)
Your Y-axis will show values between 0 and 1.
Trying to set the Y range using these values, eg.
SetRangeUser(0.01, 0.2)
will fail however.
You still need to give the range in the original unnormalized units.
You can scale normalized units back with:
Double_t scaleY = hist->GetEntries()/hist->GetNormFactor();
hist->GetYaxis()->SetRangeUser(normalizedLower*scaleY,normalizedUppe*scaleY);
===== Y Axis of a THStack =====
Do not try to ''SetLimits'' or ''SetRangeUser'' of any histogram.
Instead use the following code:
THStack *hs = new THStack("hs","test stacked histograms");
hs->SetMinimum(0.);
hs->SetMaximum(10.);
===== X Axis of TGraph =====
If you have a TGraph, SetRangeUser will not work for the x axis.
It will not complain but also not do anything. Or not the thing you want.
You have to use SetLimits(), like:
TGraph* myGraph = new TGraph();
...
myGraph->GetXaxis()->SetLimits(lower,upper);