Re: [ROOT] Two problems

From: Rene Brun (Rene.Brun@cern.ch)
Date: Thu Nov 20 2003 - 19:24:35 MET


Hi Bernard,

Bernard Andrieu wrote:
> 
> Hello,
> 
> I have two problems with root.
> 
> Problem 1:
> 
> I want to display an histogram with just its name in the stat box. According to
> the manual, I should be able to do that with:
> 
> gStyle->SetOptStat(1);
> 
> but the stat box still displays, in addition to the name,  Entries, Mean and
> RMS.
> Note that this problem is specific to the value 1 as an argument (with 0, 10,
> 11, and so on, it works as expected).

1 is a special case setting the default options. The workaround is to call
  gStyle->SetOptFit(10000001);

> 
> Problem 2:
> 
> I want to use TPaveStats to chose the position of the stat box of an histogram,
> ie:
> 
> h->Draw();
> TPaveStats *st = (TPaveStats*)h->GetListOfFunctions()->FindObject("stats");
> st->SetX1NDC(0.6) ; st->SetX2NDC(0.9) ; st->SetY1NDC(0.6) ; st->SetY2NDC(0.9);
> 
> At the command line, it works, but inside a macro, I get the following message:
> 
> Error: illegal pointer to class object st 0x0 219  FILE:detptstudy.C LINE:154
> *** Interpreter error recovered ***
> 

Read the principles of Draw/Paint for all objects. 
    http://root.cern.ch/root/HowtoDraw.html
see also Users Guide at page 29 and 111.

When executing from the command line, the canvas is automatically Updated when
pressing CR. In case of a macro, the canvas will be updated only
when you will type CR. You can force an Update of the canvas that in turn
will force the painting of your histogram and the stats box by calling
  mycanvas.Update();
after having drawn your histogram(s).

Rene Brun

> I'm using root 3.05/07 for gcc 2.95.2 on RedHat Linux 7.2.
> 
> 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
>                       ((,.-'   ((,/
> -----------------------------------------------------------------------



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