keep#

Hist2d.keep(xlower=-inf, xupper=inf, ylower=-inf, yupper=inf, squeeze=True, setval=0.0)[source]#

Return a new histogram with only bins within the specified (x, y) range.

Parameters:
xlowerfloat

Lower bound of x-axis (inclusive).

xupperfloat

Upper bound of x-axis (exclusive).

ylowerfloat

Lower bound of y-axis (inclusive).

yupperfloat

Upper bound of y-axis (exclusive).

squeezebool, default True

If True, return a cropped histogram containing only the selected region. If False, retain original shape and set bins outside the range to setval.

setvalfloat, default 0.0

Value to assign to bins outside the region if squeeze=False.

Returns:
Hist2d

A new histogram with the selected region either cropped or masked.

Raises:
ValueError

If no bins are selected and squeeze=True.