Versatile, high-performance histogram toolkit for Numpy.
histbook computes histograms from Numpy arrays. It differs from most other histogramming tools in that its histograms are primarily tables of numbers, rather than display graphics. Histograms can be filled and refilled iteratively through a large dataset, or in parallel and later combined with addition*. Histograms have arbitrarily many dimensions with convenient methods for selecting, rebinning, and projecting into lower-dimensional spaces.
Axis dimensions are managed by algebraic expressions, rather than string labels or index positions, so they are computable: an axis named
x + y requires two Numpy arrays,
y, which will be added before filling the histogram. Expressions in different axes or different histograms in the same “book” (a collection of named histograms) are computed in an optimized way, reusing subexpressions wherever possible for quicker filling without giving up clarity.
Histogram data may be exported to a variety of formats, such as Pandas, ROOT, and HEPData. It can also be plotted with Vega-Lite, which makes short work of projecting many dimensions of data as overlays and trellises.
Install histbook like any other Python package:
pip install histbook --user
or similar (use
conda if you wish).
- Pandas for more convenient programmatic access to bin contents
- Jupyter Notebook for interlaced histogramming and plotting
- JupyterLab for a complete IDE-like environment
- ipyvega to view plots in a Jupyter Notebook (not needed for JupyterLab)
- Altair to mix histograms with Altair graphics (usable in both Jupyter Notebook and JupyterLab)
- VegaScope to view plots in a web browser without Jupyter
- ROOT to analyze histograms in a complete statistical toolkit
- uproot to access ROOT files without the full ROOT framework