TH2D Color Palette glitch

Hi,

Here’s a root file containing a TH2D.

When I go into the TBrowser, and then DrawPanel, selecting ‘Col’ and ‘Palette’, I noticed a discrepancy in the representation-

that (as an example) bin x=1, y=20 is above the z axis maximum and is colored red, while bin x=1, y=19 is below the z axis minimum and is colored white.

I would expect both bins to be colored white, as neither are in the z axis range. Any explanation for why bin (1,20) is red?
test.root (6.66 KB)

Actually your histogram has a minimum set.
And the bins below the minimum are not drawn.
To reset the minimum do:

refhistdouble->SetMinimum(-1111)

so the behavior is normal… as said in the reference guide:
root.cern.ch/doc/master/classTH … .html#HP14

[quote=“couet”]Actually your histogram has a minimum set.
And the bins below the minimum are not drawn.
To reset the minimum do:

refhistdouble->SetMinimum(-1111)

so the behavior is normal… as said in the reference guide:
root.cern.ch/doc/master/classTH … .html#HP14

[quote]
When the minimum of the histogram is set to a greater value than the real minimum, the bins having a value between the real minimum and the new minimum are not drawn unless the option 0 is set.
[/quote][/quote]

Hi Oliver,

My code already had

#set palette maximum and minimum
refhistdouble.SetMaximum(10)
refhistdouble.SetMinimum(-10)

(I’m using PyROOT) So I guess by ‘real minimum’ they mean “the actual smallest bin content” and by ‘new minimum’ they mean the SetMinimum value?

So I guess that means that it’s intentional for ROOT to assign a color to bin contents above the maximum but not assign a color to bin contents below the minimum.

Yes -1111 means reset to the "real minimum"
if you want to consider the values lower than “the minimum you set” behaving like “the minimum you set”, then use the option COL0. As explained in the help.

Hi,

I have followed this thread (2D histograms with “col” option) and have commented out in my THistPainter.cxx file the line “if (z < zmin) continue;”

But when I recompile I get the same situation. Is there more that you suggest?

Thanks again

This is how it is implemented: when the content is bigger that the maximum the bin is drawn like the maximum … like a cut … (see the doc). When it is smaller that the minimum it is considered as empty and not drawn unless you use the option COL0 and in that case the bins below the minimum are drawn like the minimum.

Could there be a problem since I am using PyROOT? your example code on the help page works fine when I run it as a macro.

Here’s test code I wrote “test.py”. Both canvases appear identical although I use “COLZ” on one, and “COLZ0” on another.

Also here is macro “colz.C” that opens up the test.root file that test.py made and draws the histogram ‘test’ with the COLZ0 option, and it also draws the example code COLZ vs. COLZ0. oddly, in the example code the COLZ0 option works, but the COLZ0 option doesn’t work for the histogram ‘test’ in my ‘test.root’.
colz.C (792 Bytes)
test.py (460 Bytes)

I ran your macro and seem to me the plot produced with col0z is ok on the “test” histogram.
all is green (0 on the palette ) except one bin at -100 which also appears with de right color.