https://github.com/aminnj/yahist
1D and 2D histogram objects
https://github.com/aminnj/yahist
histogram matplotlib numpy plotly plotting
Last synced: 10 months ago
JSON representation
1D and 2D histogram objects
- Host: GitHub
- URL: https://github.com/aminnj/yahist
- Owner: aminnj
- Created: 2019-10-28T22:30:29.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-05-18T01:27:22.000Z (over 1 year ago)
- Last Synced: 2025-03-28T11:11:37.315Z (10 months ago)
- Topics: histogram, matplotlib, numpy, plotly, plotting
- Language: Python
- Homepage:
- Size: 9.08 MB
- Stars: 10
- Watchers: 1
- Forks: 3
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Yet another histogram

[](https://pypi.python.org/pypi/yahist/)
[](https://aminnj.github.io/yahist/)
[](https://mybinder.org/v2/gh/aminnj/yahist/master?filepath=examples%2Fbasic.ipynb)
```bash
pip install yahist
```
### Examples ([API docs](https://aminnj.github.io/yahist/))
[](https://mybinder.org/v2/gh/aminnj/yahist/master?filepath=examples%2Fbasic.ipynb)
(static [nbviewer](https://nbviewer.jupyter.org/url/github.com/aminnj/yahist/blob/master/examples/basic.ipynb) if Binder is slow)
### Overview
Histogram objects (1D and 2D) with easy manipulations (`numpy`), plotting (`matplotlib`), and fitting (`scipy`/`iminuit`).
```python
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))")
```

```python
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](https://github.com/scikit-hep/boost-histogram)
* using the histogram as a lookup function
* serialization to/from json
...and more.