Skip to content

Commit

Permalink
fix: plot1d overlay to work for IntCat axis corrrectly (#419)
Browse files Browse the repository at this point in the history
Reported by @DryRun

---------

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
Co-authored-by: Henry Schreiner <henryschreineriii@gmail.com>
  • Loading branch information
andrzejnovak and henryiii committed Jul 3, 2024
1 parent 61a4fa0 commit f65a39c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
5 changes: 3 additions & 2 deletions src/hist/basehist.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f65a39c

Please sign in to comment.