Home | News | Documentation | Download

Problem in Draw()ing a histogram w/ variable bin size in logarithmic scale

Hi,

I want to create and Draw() a histogram w/ variable-sized bins, especially in a scale which is evenly spaced in logarithmic space.
When I create and draw such a histogram (with the following script) on a canvas with SetLogx(kFalse) there’s no problem (histograms on the left row in the attached picture), but the histogram looks strange when drawn on a canvas w/ SetLogx(kTrue) (those on the right row).

How can I fix this?

Thanks in advance.
Kazuyoshi

{
  const Double_t eb[] = {1.e0, 1.e1, 1.e2, 1.e3, 1.e4, 1.e5};

  TH1D *testH = new TH1D("testH","testH", 5,eb);
  testH->SetStats(kFALSE);

  for (Int_t bin=1; bin<=5;bin++) {
    testH->SetBinContent(bin, 3.*pow(10,(bin-1))    );
    testH->SetBinError(  bin, 3.*pow(10,(bin-1))*0.5);
  }
  
  TCanvas *can = new TCanvas("can","can");
  can->Divide(2,2);
  can->cd(1); gPad->SetGrid(); gPad->SetLogy();
  testH->Draw("");
  can->cd(2); gPad->SetGrid(); gPad->SetLogy(); gPad->SetLogx();
  testH->Draw("");
  can->cd(3); gPad->SetGrid(); gPad->SetLogy();
  testH->Draw("hist e");
  can->cd(4); gPad->SetGrid(); gPad->SetLogy(); gPad->SetLogx();
  testH->Draw("hist e");
  can->Print("testH.png");
}


Please read tips for efficient and successful posting and posting code

ROOT Version: 6.20/02
Platform: linuxx8664gcc(Fedora release 31 (Thirty One))
Compiler: g++ (GCC) 9.2.1 20190827 (Red Hat 9.2.1-1)


I do not get the same plot with ROOT master:

I need to see why it is different. Is the plot I get with master fine for you ?

Yes, these plots are absolutely fine for me.
At home, I’ve built an executable from ROOT master, and with it I got the same plots as you attached!

commit bf3d7a52f516e722d946b171d59acbb9bce960e0

On the other hand, using the binary (on the same home PC) built from v6-20-02 git source, the results are the same as those in my first post.

So the master is better in that case.