TH2Poly::Draw("text") omitting negative numbers

Hi,

I run the following code:

from ROOT import TCanvas, TH2Poly, TH2F
from array  import array

c = TCanvas()

# Try with TH2F
h2 = TH2F("h2","",2,0,2,1,0,1)
h2.Fill(0.5,0.5, -1) 
h2.Fill(1.5,0.5,  1)  

h2.Draw("text")
c.Print("test_th2f.png")

# Try with TH2Poly
h3 = TH2Poly()
x1 = [0,1,1,0] # Define one square bin
y1 = [0,0,1,1]
x2 = [1,2,2,1] # Define a second
y2 = [0,0,1,1] 
arr_x1 = array('d',x1)
arr_y1 = array('d',y1)
arr_x2 = array('d',x2)
arr_y2 = array('d',y2)
h3.AddBin(4,arr_x1,arr_y1)
h3.AddBin(4,arr_x2,arr_y2)
h3.Fill(0.5,0.5,-1)
h3.Fill(1.5,0.5, 1)

h3.Draw("text")
c.Print("test_th2poly.png")

But only the text marker corresponding to the positive bin is shown for the TH2Poly. Do you know why? I was expecting behaviour identical to the TH2F case.

Thanks in advance,
Dan


Please read tips for efficient and successful posting and posting code

ROOT Version: Multiple [most recently 6.16.00]
Platform: SLC6
Compiler: gcc8


For some reason the Minimum of the TH2Poly is 0 .
Try GetMinimum() on it…
If you do:

h2.SetMinimum(-3);

It will work. This needs to be investigated.

Confirmed, thank you for the super-quick fix!

That’s not fix. It’s a workaround. The fix will come later. I need to understand why negative minimum does not work.

Now fixed in ROOT master. Thanks to have seen it.

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