Skip to content

Commit f65a39c

Browse files
fix: plot1d overlay to work for IntCat axis corrrectly (#419)
Reported by @DryRun --------- Signed-off-by: Henry Schreiner <[email protected]> Co-authored-by: Henry Schreiner <[email protected]>
1 parent 61a4fa0 commit f65a39c

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

docs/changelog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## WIP
4+
5+
* Support IntCat for plot1d overlay
6+
[#419](https://github.com/scikit-hep/hist/pull/419)
7+
38
## Version 2.7.3
49

510
This release fixes an issue with Python 3.12 pulling in NumPy 2 pre-releases.

src/hist/basehist.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -502,8 +502,9 @@ def plot1d(
502502
(overlay,) = (i for i, ax in enumerate(self.axes) if ax.traits.discrete)
503503
assert overlay is not None
504504
cat_ax = self.axes[overlay]
505-
cats = cat_ax if cat_ax.traits.discrete else np.arange(len(cat_ax.centers))
506-
d1hists = [self[{overlay: cat}] for cat in cats]
505+
icats = np.arange(len(cat_ax))
506+
cats = cat_ax if cat_ax.traits.discrete else icats
507+
d1hists = [self[{overlay: cat}] for cat in icats]
507508
if "label" in kwargs:
508509
if not isinstance(kwargs["label"], str) and len(kwargs["label"]) == len(
509510
cats

0 commit comments

Comments
 (0)