Re: [ROOT] Title of TF2's

From: Fons Rademakers (Fons.Rademakers@cern.ch)
Date: Fri Jul 27 2001 - 16:53:25 MEST


There is no automatic way to center the title as far as I can remeber.
You could do something like:

{
     gROOT->Reset();
     TCanvas* canvas = new TCanvas("oscprob","Survival Probability");
     canvas->cd();

     oscprob = new TF2("oscprob","1-sin(1.27*y*731.0/x)^2",0.0,10.0,1e-3,10e-3); 
     oscprob->SetTitle("Probability");
     oscprob->Draw("COL");
     canvas->Update();
     TPaveText *p = canvas->GetPrimitive("title");
     gStyle->SetTitleX(0.5 - (p->GetX2NDC() - p->GetX1NDC())/2.);
     oscprob->Draw("COL");
     canvas->Modified();
     canvas->Update();
}

but there may be another way. Like what Perrot Luc said about using
SetTitle() which obviously is the right way in this case.

Cheers, Fons.



Brett Viren wrote:
> 
> Thanks,
> 
> Your suggestion works fine (as does using oscprob->SetTitle() just
> after creation, as suggested to me by Perrot Luc).
> 
> One more detail which I haven't found by Googling around root.cern.ch:
> How can one center the TF2's TH2's overall title from code?
> 
> -Brett.

-- 
Org:    CERN, European Laboratory for Particle Physics.
Mail:   1211 Geneve 23, Switzerland
E-Mail: Fons.Rademakers@cern.ch              Phone: +41 22 7679248
WWW:    http://root.cern.ch/~rdm/            Fax:   +41 22 7677910



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:53 MET