Bug when drawing option B + Log scale X?

Hi,

I am not sure if this is a bug. The following code should draw a histogram bar with Log scale in X axis. However, bins look empty after the second bin.

import ROOT

h = ROOT.TH1D("h","",10,0,10)
h.FillRandom("pol0")
h.Draw("B")
ROOT.gPad.SetLogx()

There is an workaround, which consist in using the fill color option instead of the bar drawing option:

import ROOT

h = ROOT.TH1D("h","",10,0,10)
h.FillRandom("pol0")
h.SetFillColor(1)
h.Draw()
ROOT.gPad.SetLogx()

Thank you for your time.

Best,
atd


ROOT Version: 6.26/06
Platform: ubuntu 22
Compiler: gcc 11


Yes, the default bar color needs to be changed.
It is a bad feature.

{
auto h = new TH1D("h","",10,0,10);
h->FillRandom("pol0");
h->SetFillColor(1);
h->Draw("B");
}

The problem arises when you apply log X, all bin content except the first one dissappear if draw option B is used. The following code do not draw the histogram as expected

{
auto h = new TH1D("h","",10,0,10);
h->FillRandom("pol0");
h->SetFillColor(1);
h->Draw("B");
gPad->SetLogx()
}

Even without log scale the pad is blank. Try:

auto h = new TH1D("h","",10,0,10);
h->FillRandom("pol0");
h->Draw("B");

I see the other issue with log X and option B. without option B the plot is ok.

Yes, you are right, there are actually two issues :slight_smile:

Indeed the “B” option does not make sense in the LogX scale. The doc should be updated. The “B” option is meant to produce this kind of plot : It goes not make sense in log.
I will investigate the color issue.

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