Re: [ROOT] uniform text size for multiple pads in same canvas

From: Rene Brun (Rene.Brun@cern.ch)
Date: Mon Oct 04 2004 - 17:54:20 MEST


Hi Peter,

Use a pfont with precision 3 (default is precision 2).
With precision 3, the font size is expressed in pixels instead of per cent
of the pad height.
see:http://root.cern.ch/root/htmldoc/TAttText.html

and see a practical example below

Rene Brun

 
void fpixel() {
   TCanvas *c1 = new TCanvas("c1","test fonts",800,1000);
   TPad *pad1 = new TPad("pad1","top pad",0.2,0.6,0.8,0.99);
   pad1->Draw();
   TPad *pad2 = new TPad("pad2","bottom pad",0,0,1,0.5);
   pad2->Draw();
   pad1->cd();
   TH1F *h1 = new TH1F("h1","test fonts",100,-3,3);
   h1->GetXaxis()->SetLabelFont(63);
   h1->GetXaxis()->SetLabelSize(14); // labels will be 14 pixels
   h1->GetYaxis()->SetLabelFont(63);
   h1->GetYaxis()->SetLabelSize(14); // labels will be 14 pixels
   h1->FillRandom("gaus",5000);
   h1->DrawCopy();
   pad2->cd();
   h1->SetMarkerStyle(21);
   h1->Draw("e1p");
}   
   


Peter Steinberg wrote:
> 
> I am trying to make a canvas with multiple pads of
> different size (say a 2:3 aspect ratio canvas with a
> "square pad" on the top and a rectangle in the bottom).
> When i put my 2D histograms into these pads (in order
> to overlay various TGraphErrors), i have always had
> trouble making sure the axis labels and titles had the
> same font size.  The usual values (e.g. 0.06) have
> very different results when the pad aspect ratios
> are so different.
> 
> Does anyone have any advice on how to make sure i have
> the same text size everywhere on my canvas, even with
> very different size (& aspect ratio) pads?
> 
> Thanks,
> Peter
> 
> --
> Dr. Peter Steinberg
> 
> Associate Scientist                       Brookhaven National Laboratory
> Office: +1 631-344-4390                  t-Mobile (SMS): +1 917-443-7417
> Email: peter.steinberg@bnl.gov    Web: http://www.rhic.bnl.gov/~steinber



This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:09 MET