Re: problem with drawing two histgrams in the same canvas

From: Olivier Couet <Olivier.Couet_at_cern.ch>
Date: Thu, 30 Mar 2006 11:22:15 +0200 (CEST)

Hi,

 I tried to simulate your problem with the following example (derived from twoscales.C in tutorial)

{

   TCanvas *c1 = new TCanvas("c1","hists with different scales",600,400);    gStyle->SetOptStat(kFALSE);                                                                                 

   //create/fill draw h1
   TH1F *h1 = new TH1F("h1","my histogram",100,-3,3);    Int_t i;
   for (i=0;i<10000;i++) h1->Fill(gRandom->Gaus(0,1));    h1->Draw();
   c1->Update();                                                                                 

   //create hint1 filled with the bins integral of h1    TH1F *hint1 = new TH1F("hint1","h1 bins integral",100,-3,3);    Float_t sum = 0;
   for (i=1;i<=100;i++) {

      sum += h1->GetBinContent(i);
      hint1->SetBinContent(i,sum);
   }
                                                                                

   //scale hint1 to the pad coordinates
   Float_t rightmax = 1.1*hint1->GetMaximum();    Float_t scale = gPad->GetUymax()/rightmax;

   hint1->SetLineColor(kRed);
   hint1->Scale(scale);
   hint1->Draw("same");

}

For me it works. I do not have any statistics.

 Cheers, Olivier

On Thu, 30 Mar 2006, Xianguo Lu wrote:

> Dear Rooters,
>
>
>
> I want to draw two histgrams in one canvas:
>
>
>
> h1->Draw();
>
> gStyle->SetOptStat(0);
>
> h2->Draw("same");
>
> gStyle->SetOptStat(0);
>
>
>
>
>
> For the first one, the StatBox does not appear, but for the second, the
> StatBox is still displayed. How can I make the StatBoxes in the two
> histgrams NOT being displayed?
>
>
>
> Thanks in advance!
>
>
>
> Cheers!
>
> Xianguo Lu
>
>
>
> PKU, China
>
>
>
>

-- 
Org:    CERN - European Laboratory for Particle Physics.
Mail:   1211 Geneve 23 - Switzerland                     Mailbox: J25910      
E-Mail: Olivier.Couet_at_cern.ch                            Phone:   +41 22 7676522
WWW:    http://cern.ch/Olivier.Couet/                    Fax:     +41 22 7670300
Received on Thu Mar 30 2006 - 11:22:22 MEST

This archive was generated by hypermail 2.2.0 : Mon Jan 01 2007 - 16:31:58 MET