Re: [ROOT] Zoom

From: Rene Brun (Rene.Brun@cern.ch)
Date: Mon Oct 02 2000 - 12:56:14 MEST


Hi Anton,
If you use a TH2F to set the X,Y scale before drawing your TGraphs,
you can find the zoom position of both axis with:
   int firstXbin =h->GetXaxis()->GetFirst();
   int lastXbin  =h->GetXaxis()->GetLast();
   int firstYbin =h->GetYaxis()->GetFirst();
   int lastYbin  =h->GetYaxis()->GetLast();
then, get the corresponding coordinates with
  double xmin = h->GetXaxis()->GetBinLowEdge(firstXbin);
  double xmax = h->GetXaxis()->GetBinUpEdge(lastXbin);
  double ymin = h->GetYaxis()->GetBinLowEdge(firstYbin);
  double ymax = h->GetYaxis()->GetBinUpEdge(lastYbin);
you can also do simply:
  double xmin = gPad->GetUxmin();
  double xmax = gPad->GetUxmax();
  double ymin = gPad->GetUymin();
  double ymax = gPad->GetUymax();
Note that the maximum zoom precision depends on the number of bins
allocated for each axis.

Rene Brun


KOSU_FOKIN@garbo.lucas.lu.se wrote:
> 
> Hello Rene,
> 
> assume I have a graph drawn on top of a TH2 histogram (as we usually do in
> ROOT to draw multiple graphs on the same picture). Assume I zoom a histogram
> along X axis.  Now in my code I want to zoom the histogram along Y axis so
> that zoomed (along X) portion of graph fits Y histogram range. To do so I have
> to know Ymin and Ymax of my graph on the zoomed X. How can I get it? I have tried
> TH2::GetMinimum() and TH2::GetMaximum() but they both return zero all the
> time.
> 
> Regards,
> Anton



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:34 MET