From f65a39cebd7ec98235cc4a4f0c99e2359402a97d Mon Sep 17 00:00:00 2001 From: Andrzej Novak Date: Wed, 3 Jul 2024 17:16:47 -0400 Subject: [PATCH] fix: plot1d overlay to work for IntCat axis corrrectly (#419) Reported by @dryrun --------- Signed-off-by: Henry Schreiner Co-authored-by: Henry Schreiner --- docs/changelog.md | 5 +++++ src/hist/basehist.py | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index 2a97d5ce..017cb536 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -1,5 +1,10 @@ # Changelog +## WIP + +* Support IntCat for plot1d overlay + [#419](https://github.com/scikit-hep/hist/pull/419) + ## Version 2.7.3 This release fixes an issue with Python 3.12 pulling in NumPy 2 pre-releases. diff --git a/src/hist/basehist.py b/src/hist/basehist.py index 027cb320..358d2ef4 100644 --- a/src/hist/basehist.py +++ b/src/hist/basehist.py @@ -502,8 +502,9 @@ def plot1d( (overlay,) = (i for i, ax in enumerate(self.axes) if ax.traits.discrete) assert overlay is not None cat_ax = self.axes[overlay] - cats = cat_ax if cat_ax.traits.discrete else np.arange(len(cat_ax.centers)) - d1hists = [self[{overlay: cat}] for cat in cats] + icats = np.arange(len(cat_ax)) + cats = cat_ax if cat_ax.traits.discrete else icats + d1hists = [self[{overlay: cat}] for cat in icats] if "label" in kwargs: if not isinstance(kwargs["label"], str) and len(kwargs["label"]) == len( cats