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:
- xlower
float Lower bound of x-axis (inclusive).
- xupper
float Upper bound of x-axis (exclusive).
- ylower
float Lower bound of y-axis (inclusive).
- yupper
float 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.
- setval
float, default 0.0 Value to assign to bins outside the region if squeeze=False.
- xlower
- Returns:
Hist2dA new histogram with the selected region either cropped or masked.
- Raises:
- ValueError
If no bins are selected and squeeze=True.