Editting Statbox in a divided canvas

so now i am drawing histograms in a divided canvas. I think i can access the statbox in a way that similar to ROOT: TPaveStats Class Reference. But It turns out that the codes is trying to access a null pointer. i dont quite understand why it can work in a single plot as in the link but not in the divided canvas. Any suggestion ?

ROOT.gStyle.SetTitleX(0.1)

c = ROOT.TCanvas("c","average acceptance",3600,2400)
c.Divide(6,4)
for i in range(24):
    csub = c.cd(i+1)
    h = array_of_hs[i]
    h.Draw("colz")
    
    ROOT.gPad.Update()
    st = h.FindObject("stats")
    st.SetX1NDC(0.78)
    st.SetY1NDC(0.78)
    st.SetX2NDC(0.92)
    st.SetY2NDC(0.95)

c.Draw()

_ROOT Version: 6.26 (conda)
_Platform: ubuntu 20.02 (wsl)
Compiler: gcc9


Do you actually see the “stats” box drawn?

BTW. After modifying the “stats” position, add: ROOT.gPad.Modified() ; ROOT.gPad.Update()

ROOT.gPad.Modified() worked

So, add it also before the first “Update”.

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