The normal way to change the display range of an axis is:
but there are several situations where this fails. See below for help in these cases.
Assume you have a histogram which has been normalized it with
Your Y-axis will show values between 0 and 1. Trying to set the Y range using these values, eg.
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);
Do not try to
SetRangeUser of any histogram.
Instead use the following code:
THStack *hs = new THStack("hs","test stacked histograms"); hs->SetMinimum(0.); hs->SetMaximum(10.);
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);