Pyroot customize the bin center

so I’m filling the histogram with SetBinContent, 8 bins and range from -2.5 to 2.5. I’m wondering how to customize the bin center instead of the bin distribute evenly (like 2.5*2/8 bins)?

i wish to set bins like this:

You can define “bin edges”. Search for “variable bin size” in the TH1 class reference.

import array
import ROOT

edges = array.array('d', [-2.5, -2.0, -1.566, -1.4442, -0.8, 0.0, 0.8, 1.4442, 1.566, 2.0, 2.5])
hratio = ROOT.TH1D('hratio', 'Test random;some X;some Y', len(edges) - 1, edges)

hratio.FillRandom('gaus')
hratio.Draw()

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