norm_row_to_max#

Hist2d.norm_row_to_max()[source]#

Normalize each row to their maximum.

Returns:
new_hist2dHist2d

A new histogram where the rows are normalized.

Examples

import matplotlib.pyplot as plt
import numpy as np

import atompy as ap

plt.style.use("atom")

rng = np.random.default_rng(42)
lim = (-2, 2)
size = 1_000

hist = ap.Hist2d(*np.histogram2d(*rng.normal(size=(2, size)), range=(lim, lim)))

_, axs = plt.subplots(1, 2, layout="compressed", figsize=(6.0, 3.0))
for ax in axs:
    ax.set_box_aspect(1)

hist.plot(ax=axs[0], title="Original histogram")
hist.norm_row_to_max().plot(ax=axs[1], title="Row-normalized histogram")

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

../../../_images/norm_row_to_max.png