Re: [ROOT] Title of TF2's

From: Fons Rademakers (Fons.Rademakers@cern.ch)
Date: Fri Jul 27 2001 - 15:27:42 MEST


The problem is that for TFn drawing we use an intermediate histogram.
To do what you want you have to change the title of this histogram.
However, this can only be done after the TF has been drawn, because
before the histogram does not exist. The "title" primitive is always
regenerated so changing it does not help.

We hope to improve this interface in the not so distant future.

Cheers, Fons.


{
     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->Draw("COL");
     oscprob->GetHistogram()->SetTitle("Survival prob");
     canvas->Modified();
     canvas->Update();
 }


Brett Viren wrote:
> 
> While on the subject of titles....  I have a simple TF2 and I want to
> change the associated TPaveText from holding the formula to holding a
> text label.  Here is a script:
> 
>  {
>      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->Draw("COL");
>      canvas->Modified();
>      canvas->Update();
> 
>      TPaveText* pt = (TPaveText*) canvas->GetPrimitive("title");
>      pt->Clear();
>      pt->AddText("Survival prob");
>  }
> 
> However the formula remains.  I have also tried various interactive
> maneuvers on the TPaveText.  I can succeed in clearing or appending
> the text, but not replacing it.  What am I doing wrong?
> 
> Thanks,
> -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