Re: [ROOT] Statbox when plotting two histograms

From: Rene Brun (Rene.Brun@cern.ch)
Date: Thu Feb 13 2003 - 08:58:49 MET


Hi Meta,

do:
  tree->Draw("_Nmuon");
  TH1F *h1 = (TH1F*)gPad->GetPrimitive("htemp");
  TPaveStats *p = (TPaveStats*)h1->GetListOfFunctions()->FindObject("stats");
  p->SetX1NDC(0.4);  //change the position of the stats box for the first plot
  p->SetX2NDC(0.6);
  stree->Draw("_Njet","","sames"); // note "sames" as 3rd argument, not 2nd

Rene Brun

Meta Binder wrote:
> 
> Hi rooters
> 
> I plot two histos in one TPad. The Statbox for the first is drawn , but
> NOT for the second histo. I found a solution but its quite long. Is there
> a shorter option?
> 
> This is my code:
> 
>   tree and stree are TChains
> 
>   TCanvas *can = new TCanvas("can","can",90,90,1000,900);
>   can->Divide(2,2);
> 
>   can->cd(1);
>   tree->Draw("_Nmuon");
>   stree->Draw("_Njet");
>   TH1F *h1 = (TH1F*)gPad->GetPrimitive("htemp");
>   TPaveStats *p = (TPaveStats*)h1->GetListOfFunctions()->FindObject("stats");
>   stree->Draw("_Njet","sames");
> 
> Thank you so much
> Meta
> 
> --
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> "Thank you" means you don't have to, but I'm glad you did!
> 
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Meta Binder                  FNAL, M.S. 357
> LMU Muenchen                 Meta Binder
> Sektion Physik               P.O. Box 500
> Am Coulombwall 1             Batavia, IL 60510
> 85748 Garching
> 
> ph: +49 89 289- 14149        ph:  +1 630 840 3696
>                              fax: +1 630 840 6650



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