Re: TAxis::SetLimits()...

From: Rene Brun (
Date: Tue Nov 09 1999 - 16:04:42 MET

Hi Volker,
As you have found, the command line equivalent of a zoom with the mouse
  axis->SetRange(firstbin, lastbin);
The parameters are integers and are the first and last bin that you want
to see. I CANNOT implement SetRange with axis values. Many reasons:
 - an histogram is defined with fix size or variable size bins.
 - The bin contents have already been set. cannot rebin to the new
   without refilling.
 - In these conditions, which convention for the cut? low edge of the
   corresponding to the cut ?, center, upper edge ? What about variable
   size histograms?
 - the system must work for all dimensions, not only 1-d.

 - If I authorize the cut on axis values, I get immediatly the
   from people who will see a different value selected by the system (eg
   low edge of the bin corresponding to xmin, upper edge of the bin
   corresponding to xmax).
   In this case, I will immediatly get "suggestions for improvement" of
   style: if the cut is closer to the low edge of the bin, take the low
   otherwise the upper edge, etc.

In case of functions, the situation is different. One could perfectly
recompute the internal histogram/graph used to draw the function.
I would simply have to always delete the temporary histogram object.
However, I had many requests to not do so. There are examples of
that take a very long time to compute.

You can easily find the bin number corresponding to an axis value;
  Int_t bin = axis->FindBin(Float_t x);
The API with bin numbers forces you to understand what the result will

Note that TAxis::SetLimits is used by TF1 and TGraph. I agree that the
is may be misleading. The doc should give better explanations of all

Rene Brun

Volker Boerchers wrote:
> Hi,
> by using the mouse on an axis of a histogram display I can change the
> displayed range, but this is quite inaccurate. So how can this be done
> exactly, e.g. on the command line?  As an example I use the ntuple
> defined in the tutorials/hsimple.root file and make a 1D histogram of
> `pz' using the browser.
> 1) X-axis
> * My first guess was TAxis::SetLimits().
>   htemp->GetXaxis()->SetLimits(0,15)
> works but instead of only changing the width of the view on the
> histogram this simply exchanges the ticklabels so that the result is
> simply wrong! (Maybe this function should be excluded from the user
> interface?)
> * My next guess was SetRange(). The context menue of TAxis has an entry
> for SetRange(). Used for the xaxis of a TF1 it restricts the display
> to the selected bins, so this is nearly as good as what you can do
> with the mouse. But apart from the fact, that SetRange() only accepts
> integer arguments the dialog of SetRange does not suggest a useful
> default (0-0 instead of 0-nbins), so its not easy to find out the
> right value.
> 2) Y-axis
> Since the TAxis methods doesn't work at all for the y-axis of a 1d
> histogram one has to use htemp->SetMaximum() and SetMinimum() instead.
> What I would like best is a pair of "orthogonal" functions: one that
> changes the axis range (where the axis starts and where it ends) and
> another that limits the histogram to a certain range, e.g.
>  htemp->GetXaxis()->SetAxisRange(0,20)
>  htemp->GetXaxis()->SetCut(0,14)
> This should lead to a display of pz=0..20 with a line starting at pz=0
> and ending at pz=14. (This could make sense for a log plot to cut off
> the low statistic tail of the distribution.)
> I could imagine this functionality is already there but I couldn't
> find it in the documentation.
> Best regards,
>   Volker
> my ROOT version is 2.23/08
> ::.::::.::::.::::.::::.::::.::::.::::.::::.::::.::::.::::.::::.::::.::
> Volker B"orchers, Uni Bremen, NW1, Raum 03160, Tel. +49-421-218-4522

This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:42 MET