Re: [ROOT] min and max of Y-axis

From: Rene Brun (Rene.Brun@cern.ch)
Date: Thu Oct 03 2002 - 00:21:15 MEST


Use gPad->GetUymax in this case. Make sure that gPad
points to the pad.
Remember that in a macro, the following logic is not sufficient:
{
  TCanvas *c = new TCanvas();
  h->Draw();
  gPad->GetUymax();
}

At the time you call gPad->GetUymax, the histogram has not yet been paint.
The Draw function simply adds a reference to the histogram in the list of
primitives. You must force the histogram to be paint with:

{
  TCanvas *c = new TCanvas();
  h->Draw();
  c->Update();
  gPad->GetUymax();
}

see: http://root.cern.ch/root/HowtoDraw.html

Rene Brun


On Thu, 3 Oct 2002, Guillaume Blanc wrote:

> Hi,
> 
> Actually this is not the maximum value of the histogram I want, but the
> maximum value of the Y axis on the pad, which is about h->GetMaximum() + 10%.
> Is there something to get this value precisely?
> 
> Or: how to put an second X axis exactly on top on the plot?
> TGaxis constructor asks for xmin, ymin, xmax, ymax values... I can get the
> xmin, xmax values from h->GetXaxis()->GetXmin() and GetXmax(), but I can't
> for the ymin,ymax values...
> 
>               Guillaume Blanc
> 
> 
> On Wed, 2 Oct 2002, Rene Brun wrote:
> 
> > Hi,
> >
> > I assume that you want to access the maximum value of a histogram and
> > not the maximum value in Y of the pad. If yes, use
> >   h->GetMaximum();
> >
> > Rene Brun
> >
> > On Thu, 3 Oct 2002, Guillaume Blanc wrote:
> >
> > > Hello,
> > >
> > > Perhaps this question is obvious, but I would like to get the max value on
> > > the Y axis of a TH1F histo. I tried : h->GetYaxis()->GetXmax() but it
> > > doesn't work (return a wrong value); note that the equivalent command
> > > works for the X axis. And gPad->GetUymax() returns also a
> > > wrong value (closer to the one expected, but still wrong)...
> > > I just would to add another X axis on top of my plot with a different
> > > scale: I need the Y axis max value in order to position it accurately...
> > >
> > > Well, if anybody has a idea!
> > >
> > > Thanks for your help,
> > >
> > >                   Guillaume Blanc
> > >
> >
> >
> 



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:12 MET