Re: [ROOT] gStyle in sub-pads?

From: Rene Brun (Rene.Brun@cern.ch)
Date: Fri Nov 21 2003 - 12:46:13 MET


Bernard,

Why to do things complicated when they can be simple?

In your case, you are calling the Fit fonction. By default this fonction 
draws the results of the fit and creates the TPaveStats.
Then you set the style options.
Then you redraw the histogram.

Simply do:

{
gStyle->SetOptStat(10000001); gStyle->SetOptFit(111);
h_jets_emf.Fit("gaus","","pe",0.3,0.9);
}

In version 3.10/01, calling gStyle->SetOptFit or SetOptStat redraws
automatically the stats box with the current parameters.

Rene Brun

Bernard Andrieu wrote:
> 
> Hi Rene,
> 
> please find attached the simplest example with which I can reproduce the problem
> (I did not send the 1d-histogram since I don't think it is the origin of the
> problem) and the resulting ps.
> 
> I'm using root 3.05/07 for gcc 2.95.2 on RedHat Linux 7.2.
> 
> In fact, the problem is not related specifically to subpads, but to a subtle (at
> least for me) interplay between c1.Clear() and gStyle.
> 
> In this example, of course, I could remove the c1.Clear() statement, then it
> works. But if I want to use subpads, I need to do a c1.Clear() at some point,
> which is why I discovered the problem when using subpads and thought it was
> related to these.
> 
> Thanks in advance.
> --
>                       Best regards,
>                                Bernard Andrieu
> -----------------------------------------------------------------------
>                          ("-/")_.-'"-._
> LPNHE, 4 pl. Jussieu      . . ; -._    )-;-,_)  email: andrieu@in2p3.fr
>     Tour 33, RdC         (v_,)'  _  )-.\  -'    Tel: +33 (0)1 4427 2321
> 75252 PARIS CEDEX 05    _.- _..-_/ / ((.'       Fax: +33 (0)1 4427 4638
>                       ((,.-'   ((,/
> -----------------------------------------------------------------------
> 
> Rene Brun a écrit :
> >
> > Bernard,
> >
> > I cannot reproduce your problem. Please indicate the version in use
> > and provide an example as explained at:
> >
> > http://root.cern.ch/root/roottalk/RoottalkRules.html
> >
> > Rene Brun
> >
> > Bernard Andrieu wrote:
> > >
> > > Hello,
> > >
> > > is there a way to propagate the gStyle options to all subpads of a given pad?
> > >
> > > To be more specific, I want to display the results of several (say 4) histograms
> > > fits on a multi-zone plot. If I do:
> > >
> > > gStyle->SetOptStat(10000001); gStyle->SetOptFit(111);
> > > c1.Clear() ; c1.Divide(2,2);
> > > c1.cd(1); h1->Draw();
> > > c1.cd(2); h2->Draw();
> > > c1.cd(3); h3->Draw();
> > > c1.cd(4); h4->Draw();
> > >
> > > the stat boxes of the displayed histograms shows the usual Entries, Mean, RMS
> > > and not the results of the fit, in contrast to what is expected. To obtain what
> > > I wish, I need to add for each subpad, ie after each c1.cd(..) command:
> > > gStyle->SetOptFit(111);
> > >
> > > Is there a simpler way to obtain the same result?
> > >
> > > Thanks for help.
> > > --
> > >                       Best regards,
> > >                                Bernard Andrieu
> > > -----------------------------------------------------------------------
> > >                          ("-/")_.-'"-._
> > > LPNHE, 4 pl. Jussieu      . . ; -._    )-;-,_)  email: andrieu@in2p3.fr
> > >     Tour 33, RdC         (v_,)'  _  )-.\  -'    Tel: +33 (0)1 4427 2321
> > > 75252 PARIS CEDEX 05    _.- _..-_/ / ((.'       Fax: +33 (0)1 4427 4638
> > >                       ((,.-'   ((,/
> > > -----------------------------------------------------------------------
> 
>   --------------------------------------------------------------------------------
> {
> h_jets_emf.Fit("gaus","","",0.3,0.9); gPad->Update();
> 
> c1.Clear();
> gStyle->SetOptStat(10000001); gStyle->SetOptFit(111); gStyle->SetOptFit(kTRUE);
> 
> h_jets_emf->Draw("pe");
> }
> 
>   --------------------------------------------------------------------------------
>               Name: demo.ps
>    demo.ps    Type: Postscript Document (application/postscript)
>           Encoding: 7bit



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:17 MET