Incorrect information in jupyROOT 2d histograms

The hover information for bin in interactive 2D histograms in jupyter lab (jupyROOT) seems to be pythonic rather than ROOT/C++ (See attached screenshot).
Unless, I am mistaken, the first bin in ROOT should be indexed as Bin 1 not Bin 0. If we query the LowEdge for bin 0 in ROOT, then it says -1 and not 0 as given by the hover information bubble.
This bahviour is not present for 1D histograms. Also, if I save the histogram in a .root file and open with TBrowser, it shows the bin indexing according to ROOT convention.


_ROOT Version: ROOT 6.24/06
_Platform: Ubuntu
Compiler: Not Provided


Can you provide data saved in ROOT file?


This is just some code I wrote to investigate this behaviour from jupyroot. You can reproduce this behaviour by running this code in jupyterlab:

from ROOT import *
import numpy as np


arr_0 = np.array([1,2,3,4,5,6,7])

arr_root2d = TH2F("sample_hist_2d", "Hist_title", 10, 0, 10, 10, 0, 10)

for myindexi, myelement in enumerate(arr_0):
    for myindexj, myelement in enumerate(arr_0):
        arr_root2d.SetBinContent( arr_root2d.GetBin(myindexi + 1, myindexj + 1), myelement)

C7 = TCanvas()

More information on jupyter version:

jupyter_client 7.3.4
jupyter_core 4.10.0
jupyter_server 1.17.1
jupyterlab 3.3.2
jupyterlab_pygments 0.2.2
jupyterlab_server 2.12.0

Now I see.

In JSROOT tooltips bins numbering starts from 0 - not from 1.
One should increase it by 1 to use in TAxis::GetBinLowEdge.

I will fix it in next JSROOT versions.
Thanks to reporting it!

1 Like

Ok but does that mean it only affacts the 2D plots? 1D histograms seem to be unaffected by this bug.

Yes, it was problem in 2D plots. Now it is fixed in JSROOT master branch.

OK, thanks.