atompy.Hist2d.without_yrange#

Hist2d.without_yrange(yrange)[source]#

Apply an exclusive gate along y.

Return a histogram where every bin with yxedges[0]* <= bin yedges <= yedges[1] is numpy.nan.

Parameters:
yrange(float, float)

lower/upper yedge to be excluded from the final histogram. Edges are excluded.

Returns:
new_histogramHist2d

Examples

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

plt.rcParams["image.cmap"] = "atom"

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

hist = ap.Hist2d(*np.histogram2d(x, y, 20, range=[[-2, 2],[-2, 2]]))

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

ax0.imshow(**hist.for_imshow())
ax1.imshow(**hist.without_yrange((-1, 1)).for_imshow())

ap.make_me_nice()

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

../../../../_images/without_yrange.png