Dear PyRoot expert,
I came across this strange behavior:
I was trying to retrieve the palette of an histogram, but depending on the Python/ROOT versions this seems to be not always possible.
To verify this, just have a look at these two snippets of code:
In Python:
from ROOT import TH2D,TCanvas
h = TH2D(“h”,“H”,10,0,10,10,0,10)
h.SetBinContent(1,1,100)
c = TCanvas(“c”,“C”)
h.Draw(“colz”)
print “palette = %s” %h.FindObject(“palette”)
–> output on Python 2.6.2, ROOT 5.22:
palette = None
Inside ROOT 5.22:
root [0] TH2D h(“h”,“H”,10,0,10,10,0,10)
root [1] h.SetBinContent(1,1,100)
root [2] TCanvas c(“c”,“C”)
root [3] h.Draw(“colz”)
root [4] h.FindObject(“palette”)
–> output:
(const class TObject*)0x8f03e78
So in the first case it is not possible to find the palette (None object) while the in C version this works perfectly (pointer different from NULL).
I tested the above Python code on another configuration: Python 2.5.4 and ROOT 5.18 and it worked nicely both on Python as in the ROOT interpreter.
Do you have any idea of what is going wrong?
Best regards,
Barbara