Hist

2.10.1 · active · verified Sat Apr 11

Hist is an analyst-friendly front-end for boost-histogram, providing enhanced classes and utilities for histogramming in Python. It offers features like named axes, quick construction shortcuts, and integrated plotting capabilities, building on the performance of boost-histogram. The library is actively maintained, with its current version being 2.10.1, and typically releases updates to align with Python and boost-histogram version changes.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to create a simple 1D histogram using Hist's `Hist.new` quick construction, fill it with NumPy array data, and print its representation. The example also shows how to define named and labeled axes. Plotting functionality is available with the `[plot]` extra.

from hist import Hist
import numpy as np

# Create a histogram with one regular axis
h = (Hist.new
     .Reg(10, 0, 10, name="x", label="X-axis [units]")
     .Double() # Storage type
)

# Fill the histogram with some data
data = np.random.normal(5, 1, 1000)
h.fill(x=data)

# Access counts and plot (requires matplotlib, optional install)
# import matplotlib.pyplot as plt
# h.plot()
# plt.show()

print(h)

view raw JSON →