Superimposing histograms

From: Daniel Andrade Leon <edgar.daniel.andrade.leon_at_cern.ch>
Date: Fri, 24 Aug 2007 12:02:42 +0200

Hi Rooters,

When I try to superimpose histograms, the first drawn histogram fixes the Y range and the next histogram ( "same" ) sometimes don't display the complete range. The solution could be to draw in the opposite order, but with a lot of histograms this is a very long work. And by changing the order with color filled histograms I obviously can't see all the line. I'm trying to solve this problem by setting the axis range, but it doesn't work. Please help me with some idea.

Tkank you very much

Daniel

{
gROOT->Reset();

TFile *f0 = new TFile("/space2/andrade/run/ejercicios/Ideal_histos.root"); TH1F *h0phiL1 = (TH1F *)f0->Get("h0phiL1");   

TFile *f1 = new TFile("/space2/andrade/run/ejercicios/Misaligned_histos.root"); TH1F *h1phiL1 = (TH1F *)f1->Get("h1phiL1");

TCanvas *cIM = new TCanvas("cIM", "Ideal & Misaligned Geometries");

gPad->SetLogy(0);

h1phiL1->SetLineColor(36);
h1phiL1->SetFillColor(33);

Double_t scale_h0phiL1 = 1/h0phiL1->Integral(); h0phiL1->Scale(scale_h0phiL1);

Double_t scale_h1phiL1 = 1/h1phiL1->Integral(); h1phiL1->Scale(scale_h1phiL1);

 Double_t maxh0phiL1=0.0;
 Double_t maxh1phiL1=0.0;
 maxh0phiL1=h0phiL1->GetMaximum();
 maxh1phiL1=h1phiL1->GetMaximum();
 if(maxh0phiL1>maxh1phiL1){
   h1phiL1->GetYaxis()->SetRange(0,1.1*maxh0phiL1);
}

 else{
   h1phiL1->GetYaxis()->SetRange(0,1.1*maxh1phiL1);
}

 h1phiL1->Draw();
 h0phiL1->Draw("same");

} Received on Fri Aug 24 2007 - 12:03:05 CEST

This archive was generated by hypermail 2.2.0 : Fri Aug 24 2007 - 17:50:03 CEST