Skip to content

aminnj/yahist

Repository files navigation

Yet another histogram

Python application PyPI Documentation Status Binder

pip install yahist

Examples (API docs)

Binder (static nbviewer if Binder is slow)

Overview

Histogram objects (1D and 2D) with easy manipulations (numpy), plotting (matplotlib), and fitting (scipy/iminuit).

import numpy as np
from yahist import Hist1D

v = np.random.normal(0, 1, 1000)
h = Hist1D(v, bins=100, label="data").rebin(2).normalize()
h.plot(errors=True, ms=3)
h.fit("peak * np.exp(-(x-mu)**2 / (2*sigma**2))")

import pandas as pd

df = pd.DataFrame(np.random.normal(0, 1, size=(10000, 2)), columns=["A", "B"])

h = Hist2D(df, bins="30,-3,3", threads=4)
h.plot(logz=True, cmap="cividis")
h.profile("x").plot(errors=True, color="C1", marker=".", label="x-profile")

Much more functionality is showcased in the example notebook, including

  • fitting (chi2 or likelihood)
  • interactive plots (via bokeh)
  • datetime inputs/axes
  • rebinning/subsetting
  • profiling/projecting 2D histograms
  • acceleration of 1D/2D histogram creation with boost-histogram
  • using the histogram as a lookup function
  • serialization to/from json

...and more.

Releases

No releases published

Packages

No packages published