rebin_y#

Hist2d.rebin_y(fac)[source]#

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

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

Parameters:
facint

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

Returns:
Hist2d

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

Raises:
ValueError

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

Examples

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