Re: Axis ranges

Rene Brun (Rene.Brun@cern.ch)
Fri, 12 Dec 1997 12:12:51 +0100


Bosko Ivanisevic wrote:

> Hi, I have a problem defining axis ranges. For example if I try to
> change lower and upper bound of x axis in tutorial file graph.c
> using gr->GetXaxis()->SetLimits(-2,2) c1->Modified();
> c1->Update(); nothing happens. Also, I tried to use DrawPanel option
> but it doesn't show for TGraph object. On the other hand changing the
> axis ranges for TH1 objects is very simple through slider on
> DrawPanel, but I couldn't do it in macro. Is there any way to change
> the range of x axis for TGraph object in macro?

TGraph::DrawPanel is not yet implemented.
With your version, a convenient way to set the range in a pad is
pad->DrawFrame(xmin,ymin,xmax,ymax);
and then draw the graph
gr->Draw("lp"); //do not specify option "A"

For TH1 objects, you can set the axis range in a macro with
h->GetXaxis()->SetRange(xbinmin, xbinmax)
and for a 2-d histogram
h->GetYaxis()->SetRange(ybinmin, ybinmax)

Rene Brun