Re: [ROOT] Stats box pb

From: Rene Brun (Rene.Brun@cern.ch)
Date: Wed Dec 11 2002 - 23:06:54 MET


Hi Guillaume,

Your call to SetStats is at the wrong place.
With 3.02/07, you should do this:

{
  TH1F *m15 = new TH1F("m15","test",100,-2,2);
  m15->FillRandom("gaus",2000);
  m15->Draw();

  c1->Update();
  TPaveStats* sta = (TPaveStats*) gPad->GetPrimitive("stats");
  m15->SetStats(kFALSE);

  sta->SetName("newname");
  sta->SetX1NDC(0.73);
  sta->SetX2NDC(0.95);
  sta->SetY2NDC(0.70);
  sta->SetY1NDC(0.55);
  sta->SetTextColor(4); // blue

  TH1F *m1517 = new TH1F("m1517","test2",100,-2,2);
  m1517->FillRandom("gaus",1800);
  m1517->SetFillColor(4); // blue
  m1517->Draw("sames");
}

in version 3.09/09 or the new version 3.04/01, do:
{
  TH1F *m15 = new TH1F("m15","test",100,-2,2);
  m15->FillRandom("gaus",2000);
  m15->Draw();

  c1->Update();
  TPaveStats* sta = (TPaveStats*) m15->FindObject("stats");

  sta->SetX1NDC(0.73);
  sta->SetX2NDC(0.95);
  sta->SetY2NDC(0.70);
  sta->SetY1NDC(0.55);
  sta->SetTextColor(4); // blue

  TH1F *m1517 = new TH1F("m1517","test2",100,-2,2);
  m1517->FillRandom("gaus",1800);
  m1517->SetFillColor(4); // blue
  m1517->Draw("sames");
}

Rene Brun

On Wed, 11 Dec 2002, Guillaume Blanc wrote:

> Hi rooters,
> 
> I would like to superimpose two TH1 on the same pad and get for each one a
> stat box.
> I did the folowing to get the regular stat box for the first histogram
> (m15), and a second stat box for the second histo (m1517). It works but
> the stats of the 1st histo (m15) go into the 2nd stat box and vice versa.
> 
> So, what's wrong?
> 
> ---
>   TH1F *m15 = new TH1F("m15","#Delta m_{15}", nbbin, xmin, xmax);
>   sn51->Project("m15","dm");
>   TH1F *m1517 = new TH1F("m1517","Dm15", nbbin, xmin, xmax);
>   sn17->Project("m1517","dm");
> 
>   m15->SetStats(kTRUE);
>   m15->Draw();
> 
>   c1->Update();
>   TPaveStats* sta = (TPaveStats*) gPad->GetPrimitive("stats");
> 
>   sta->SetName("newname");
>   sta->SetX1NDC(0.73);
>   sta->SetX2NDC(0.95);
>   sta->SetY2NDC(0.70);
>   sta->SetY1NDC(0.55);
>   sta->SetTextColor(4); // blue
> 
>   m1517->SetFillColor(4); // blue
>   m1517->Draw("sames"); // print the stats of the 1st histo, m15...
> 
> ---
> 
> If anybody can help me...
> (I use  version 3.02/07 on alphacxx6)
> 
> 		Guillaume Blanc
> 
> 
> _________________________________________________________________
> 
>     Guillaume BLANC               email: gblanc@cea.fr
>     DAPNIA/SPP, CEA Saclay        phone: (33) 1 69 08 85 33
>     91191 Gif-sur-Yvette cedex    fax  : (33) 1 69 08 64 28
>     France                        web  : http://1.618.free.fr
> _________________________________________________________________
> 
> 



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:23 MET