Re: [ROOT] The Title of TF1

From: Rene Brun (Rene.Brun@cern.ch)
Date: Fri Jun 11 2004 - 13:59:17 MEST


Hi,

This is a side effect of TF1::GetXaxis() that creates an intermediate histogram
(fHistogram member) and sets the title of the histogram to the current
title of the function (eg "pol4").
In Principle, one should implement a TF1::SetTitle that will set
also the title of the histogram in addition to the title of the function.
In your test2 function, replace:
  f2->SetTitle("Test Title");
by
  f2->GetHistogram()->SetTitle("Test Title");

Rene Brun

Siguang Wang wrote:
> 
> Dear Friends,
> For the next two tests, the title of the plot is "Test Title" for
> test1() while the "pol4" for the test2().
> The only difference of the two tests is: The order of two commands:
> "SetTitle" and "GetYaxis()->SetTitle".
> Is it a bug?
> 
> Thanks
> 
> Siguang WANG
> P.S.
> 
> test1()
> {
>   TCanvas *c1=new TCanvas("c1","test1",800,600);
>   TF1 *f1=new TF1("f1","pol4");
>   f1->SetParameters(1.0,2.5,8.0,-7.0,2.0);
>   f1->SetTitle("Test Title");
>   f1->GetYaxis()->SetTitle("Y Axis");
>   f1->Draw();
> }
> test2()
> {
>   TCanvas *c2=new TCanvas("c2","test2",800,600);
>   TF1 *f2=new TF1("f2","pol4");
>   f2->SetParameters(1.0,2.5,8.0,-7.0,2.0);
>   f2->GetYaxis()->SetTitle("Y Axis");
>   f2->SetTitle("Test Title");
>   f2->Draw();
> }
> 
> ^-^ ^-^ ^-^ ^-^ ^-^ ^-^ ^-^ ^-^ ^-^ ^-^ ^-^ ^-^ ^-^ ^-^ ^-^ ^-^ ^-^ ^-^
> 1e/c1 HERMES/DESY
> Notkestrass 85
> 22607 Hamburg, GERMANY
> Tel: +49-40-89983983(o)
> Mobile:   01759346290
> ^-^ ^-^ ^-^ ^-^ ^-^ ^-^ ^-^ ^-^ ^-^ ^-^ ^-^ ^-^ ^-^ ^-^ ^-^ ^-^ ^-^ ^-^



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