TH1 resizing on its own when used with SetBinLabel

Hi,

Below I create a nbin=3 histogram.
I set underflow and overflow bins et voila it increased to nbin=6.
Is this an intended behavior?

Thanks,
Philip

void test1()
{
    TH1D* hist = new TH1D("test", "test", 3, 0, 3);
    hist->GetXaxis()->SetBinLabel(1, "ee");
    hist->GetXaxis()->SetBinLabel(2, "em");
    hist->GetXaxis()->SetBinLabel(3, "mm");
    hist->SetBinContent(0, 1);
    hist->SetBinContent(1, 1);
    hist->SetBinContent(2, 1);
    hist->SetBinContent(3, 1);
    hist->SetBinContent(4, 1);
    TCanvas* c1 = new TCanvas("c1","c1",0, 0, 800, 800);
    hist->Draw("hist");
    c1->SaveAs("test1.pdf");
}
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.