TH3F does not work with log scale or binning

Hi all,


import ROOT
import numpy as np
x_bins = np.logspace(-1, 2, 11)
y_bins = np.linspace(-10, 10, 11)
z_bins = np.linspace(-10, 10, 11)

h = ROOT.TH3F("name", "title", 10, x_bins, 10, y_bins, 10, z_bins)

x_randoms = 100*np.random.random_sample(10000)
y_randoms = 20*np.random.random_sample(10000) - 10
z_randoms = 20*np.random.random_sample(10000) - 10

for x,y,z in zip(x_randoms, y_randoms, z_randoms):

c = ROOT.TCanvas()
input("Press any key and see that content does not adjusts properly to the log scale!")


Expected output

The content of 3D bins should adjust to the logarithmic scaling of the axis, alike when using TH1F or TH2F, but it does not.
The second plot is wrong.
The last x bin is from 50 to 100. Switching to the log scale changes only the labels, while the content assuming the linear scale is still drawn…


source /cvmfs/
ROOT Version: 6.30/06
Built for linuxx8664gcc on Apr 09 2024, 22:46:31
From heads/master@tags/v6-30-06
Python 3.9.12

I’ll check asap (something to finish b4)

I checked. Log scales are not supported for this of plot.
Some developments are required to support it.

I add support of log scales on TH3 plots to recent JSROOT code.

Changes will be applied soon in ROOT master and will be included also in ROOT 6.32 release.

This is how it will looks like:

1 Like

Thanks for checking and adding the support to the JSROOT!

It would be nice to add some sort of bold warning for the old TCanvas that this usage is not supported

1 Like

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