Re: Alignment of Y-Axis Labels...

From: Rene Brun (Rene.Brun@cern.ch)
Date: Sat Feb 12 2000 - 17:22:18 MET


Hi Stephan,


On Thu, 10 Feb 2000, Stephan Hurling wrote:

> 
> Dear Rooters,
> 
> I've got a small problem with the alignment of y-axis labels from a simple
> TH1-histogram. Aligning the x-axis was easy: Within the canvas I clicked
> on the x-axis until I got a TAxis::SetLabelFont popup menue and I filled
> in the number:
> 
> FontAndJustification = FontID * 10 + Justification number

This is wrong. The font parameter is FontID*10 + precision
Use precision 1 or 2
> 
> which was 133 in my case, because I wantet Times-New-Roman (FontID 13) and 
> right justification (3). When I started to do the same for the y-axis I
> failed. Justification 3 rotates the label 90 degrees clockwise and the
> label isn't parallel to the y-axis anymore (see picture 1). Justification
> 2, which is "center" leads unfortunatelly to a label, which is not really
> centered and also not aligned to the top of the y-axis (see picture 2) as
> long as I use greek symbols and "lower case letters" which I do.
> Tricks like filling up the line with whitespaces and so on failed. Can
> somebody help me?

I suggest to always use the Latex facility included in version 2.23
instead of the old PAW-style greek characters.
With Latex, you can see the result on the screen and titles are correctly
aligned. Here is an example

{
   gROOT->Reset();
   TH1F h("h","",60,-30,30);
   h.SetMaximum(500);
   TAxis *xaxis = h.GetXaxis();
   TAxis *yaxis = h.GetYaxis();
   xaxis->SetTitle("#Deltaz_{vtx}[cm]");
   xaxis->SetTitleOffset(1.7);
   xaxis->SetLabelSize(0.08);
   yaxis->SetLabelSize(0.08);
   xaxis->SetLabelFont(132);
   yaxis->SetLabelFont(132);
   yaxis->SetTitleSize(0.08);
   yaxis->SetTitle("dn/d#DeltaZ_{vtx}[cm^{-1}]");
   TCanvas c1("c1");
   c1.SetLeftMargin(0.2);
   c1.SetBottomMargin(0.15);
   h.Draw();
}   

Rene Brun

> 
> All the best / Alles Gute
> 
> Stephan
> 
> 
> +-------------------------------------------------------------------------+
> |                                                                         |
> |                                                                         |
> |    Stephan Hurling                                                      |
> |                                                                         |
> |    DESY                                  Telephone: **49 40 8998 3228   |
> |    Group FH1, Build. 1c/162              FAX      : **49 40 8998 4385   |
> |    Notkestrasse 85                                                      |
> |                                                                         |
> |    D-22607 Hamburg (Germany)             e-mail: hurling@mail.desy.de   |
> |                                                                         |
> |                                                                         |
> +-------------------------------------------------------------------------+
>  
> 



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