Re: two cosmetic questions

Rene Brun (Rene.Brun@cern.ch)
Fri, 10 Jul 1998 16:37:14 +0200


Chris Jillings wrote:
>
> Hi,
> I am trying to make nice plots for a document. My canvas is divided
> into two pads, one above the other. To make the labels large enough to
> read on paper, I use
>
> gStyle->SetLabelSize(0.08);
> gStyle->SetLabelSize(0.08,"yaxis");
>
> The problem is the x-axis labels get pushed down, out of the pad. If
> they are moved up to make them visible, they collide with the numbers.
> I think my solution is to move the frame higher up in the pad. (I don't
> use a title on the pads.) How do I do this in an automatic way?
>

To move the frame top/down/left/right, you can use
TPad::SetTopMargin(0.1);
TPad::SetBottomMargin(0.2); //default is 0.1 (10 per cent of pad)

or if you prefer at the TStyle level
gStyle->SetPadBottomMargin(0.2);

> The second question is about getting axis information. How do I get
the
> range of the y-axis. I have tried
> ymax = p1->GetUymax();
> ymin = p1->GetUymin();
> and it doesn't seem to work. Neither does TPad::GetRangeAxis().
>
> Any ideas?
>

To get info about one axis, you must go via the object that has
created the axis. This is typically a TH1F or TH2F object.
For example, when you draw a 1-D histogram
h1->Draw();
you can access the axis objects with
TAxis *xaxis = h1->GetXaxis();
TAxis *yaxis = h1->GetYaxis()
then (look in TAxis.h)
Int_t nx = xaxis->GetNbins();
Float_t xmin = xaxis->GetXmin();
Float_t xmax = xaxis->GetXmax();
Float_t ymin = yaxis->GetXmin();
Float_t ymax = yaxis->GetYmax();

In the tutorials, we show several examples with histograms, graphs
with errors or not and the different ways to access the axis info.

Rene Brun