atompy.Hist1d.without_range#

Hist1d.without_range(range_)[source]#

Return a Hist1d excluding everything within range_[0] and range_[1].

Parameters:
range_(float, float)

left/right edge of region to be excluded in the final histogram. Edges are also excluded.

keepdimsbool, default False

If True, keep original dimensions, i.e., the length of xedges won’t change

Returns:
hist1dHist1d

Examples

import matplotlib.pyplot as plt
import numpy as np
import atompy as ap

rng = np.random.default_rng(42)
x = rng.normal(size=10_000)

hist = ap.Hist1d(*np.histogram(x, bins=20, range=(-2, 2)))

_, (ax0, ax1) = plt.subplots(1, 2)

for ax in (ax0, ax1):
    ax.set_box_aspect(1./1.618)

ax0.step(*hist.for_step)
ax1.step(*hist.within_range((-1, 1), keepdims=True).for_step)

ap.make_me_nice()

(Source code, png, hires.png, pdf)

../../../../_images/without_range.png