RE: miscolored sub-bin in a bin of a THStack

From: Olivier Couet <Olivier.Couet_at_cern.ch>
Date: Thu, 2 Jul 2009 10:16:21 +0200


Hi,
Yes, your plot is correct. The total content of the last bin is 3, as it should be. The stacked is plotted from 1.
Olivier

-----Original Message-----
From: owner-roottalk_at_root.cern.ch [mailto:owner-roottalk_at_root.cern.ch] On Behalf Of Peter Speckmayer Sent: Thursday, July 02, 2009 10:11 AM
To: achilleas
Cc: roottalk (Mailing list discussing all aspects of the ROOT system.) Subject: Re: [ROOT] miscolored sub-bin in a bin of a THStack

Hi,

This is only an effect of the range you choose for the y-axis. If you set the range of the y-axis with SetUserRange to 0.1 to 10000 the last bin gets drawn as you want.

If your TAxis-range starts with 1 though, the last bin of histogram 3 is simply below the starting point of your scale.

If you set the range for example to 2 to 20, then you don't get the last bin of the second histogram either.

achilleas schrieb:
> 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 - 10:16:40 CEST

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