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

From: achilleas <lazopoli_at_phys.ethz.ch>
Date: Thu, 2 Jul 2009 13:00:31 +0200


Hi,

thanks a lot. Now, what is the way to actually change the lower plotting limit for a staked hist?

I tried

hs->Draw();
hs->GetYaxis()->SetRangeUser(200,400);
hs->Draw();


(hs being the pointer to the THStack object)

but it doesn't seem to work.

I also tried

hs->GetYaxis()->SetRangeUser(200,400);
hs->Draw();

but this gives an error: illegal pointer to class object GetYaxis()

Changing the ranges of individual histograms works fine, changing the X-range of the stacked works fine.

Thanks in advance.

Olivier Couet wrote:
> 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.
>
> - Peter
>
>
>
> 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 - 13:00:36 CEST

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