rebin_x#

Hist2d.rebin_x(fac)[source]#

Rebin the histogram along the x-axis by an integer factor.

This method reduces the number of x bins by aggregating adjacent bins along the x-axis. The number of x bins must be divisible by fac. The bin contents are summed, and new x-bin edges are constructed accordingly.

Parameters:
facint

Factor by which to reduce the number of x bins. Must be a divisor of the current number of x bins (self.xbins).

Returns:
Hist2d

A new Hist2d instance with rebinned x-axis and updated values.

Raises:
ValueError

If fac is not a divisor of the number of x bins.

Examples

>>> h = Hist2d(values, xedges, yedges)
>>> h_rebinned = h.rebin_x(2)
>>> h_rebinned.values.shape[0] == h.values.shape[0] // 2
True