miscolored sub-bin in a bin of a THStack

From: achilleas <lazopoli_at_phys.ethz.ch>
Date: Thu, 2 Jul 2009 09:55:14 +0200


Hello all,

I have the following wierd behaviour in a stack of histograms (THStack) with a logarithmic y-axis: the color (only) of the last bin of (only) one of the stacked histograms gets somehow changed into the color of another histogram. The effect dissapears when I remove the log scale at the y-axis. Note that the sum of values in the last bin is actually correct - it's only the colour that gets mixed up.

Here is the code:

void miscolored_bin() {

   THStack *hs = new THStack("hs","miscolored bin effect in stacked histograms");

   TH1F *h1_gluons = new TH1F("h1","E1 accuracy",4,0,400);
   TH1F *h1_qqgluons = new TH1F("h2","E1 accuracy",4,0,400);
   TH1F *h1_bar = new TH1F("h3","E1 accuracy",4,0,400);

    h1->Fill(50,1000.0);
    h1->Fill(150,100.0);

    h1->Fill(250,10.0);
    h1->Fill(350,1.0);   
   h2->Fill(50,1000.0);
   h2->Fill(150,100.0);
   h2->Fill(250,10.0);
   h2->Fill(350,1.0);
  
   h3->Fill(50,1000.0);
   h3->Fill(150,100.0);

   h3->Fill(250,10.0);
   h3->Fill(350,1.0);   
  h1->SetFillColor(kBlue);
  h2->SetFillColor(kGreen);
  h3->SetFillColor(kRed);
 
   hs->Add(h1);

   hs->Add(h2);
   hs->Add(h3);        

   TCanvas *c1 = new TCanvas("c1","big canvas",0,0,1200,800);     gPad->SetLogy();
    gPad->SetGrid();
    hs->Draw();          

} Received on Thu Jul 02 2009 - 09:55:23 CEST

This archive was generated by hypermail 2.2.0 : Thu Jul 02 2009 - 11:50:04 CEST