User Tools

Site Tools


Set Display Range of Axis

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.

Y Axis of a normalized Histogram

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.

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();

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");

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();
root/setaxisrange.txt · Last modified: 2014/03/11 10:20 by nchiap