Suppresion of empty bins while drawing TH1

Hi,

If I do:

h = TH1F(“h”,"",5,0,5);
h.Fill(1,0.5);
h.SetMinimum(-1);
h.SetMaximum(1);
h.Draw(“P”);

I get polymarkers in all bins, contradicting the reference page telling me that empty bins are suppressed and only shown with option “P0”.

cheers,

Mario

What you get is correct because in your case the histogram minimum value is negative. Negative content in an histogram means it as been filled with negative weights. In a such case bins with 0 content may have been filled (sum of weight being 0). Do not set the minimum to -1 and you will get the expected behavior.

I want to plot the difference of two histos which naturally can be negative (hence I need the minimum to be smaller 0). In my case a difference of zero will never occur (as both numbers are float). I.E. there are situations where “wrong/dangerous” plots are practical :smiley:

Since there are the two drawing options P and P0 why not using them :bulb: . At the moment for histos with Minimum < 0 P and P0 are identic…

cheers

Mario

As you said, in the general case, that is wrong and dangerous.