Skip to content

Commit

Permalink
Fix stat_summary_bin when using binwidth & breaks
Browse files Browse the repository at this point in the history
  • Loading branch information
has2k1 committed Aug 1, 2024
1 parent 29c77f3 commit 7a25a92
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions doc/changelog.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ title: Changelog
- Fixed bug in [](:class:`~plotnine.geoms.geom_segment`) where the lineend
parameter was ignored. ({{< issue 727 >}})

- Fixed [](:class:`~plotnine.stat_summary_bin`) to work with continuous `x`
aesthetic when specifying the `binwidth` or `breaks`. ({{< issue 824 >}})

## v0.13.6
(2024-05-09)

Expand Down
1 change: 1 addition & 0 deletions plotnine/stats/stat_summary_bin.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ def compute_group(cls, data, scales, **params):
)

breaks = fuzzybreaks(scales.x, breaks, boundary, binwidth, bins)
bins = len(breaks) - 1
data["bin"] = pd.cut(
data["x"],
bins=breaks, # pyright: ignore
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions tests/test_stat_summary_bin.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,8 @@ def test_continuous_x():
)

assert p == "continuous_x"


def test_setting_binwidth():
p = ggplot(data, aes("xc", "y")) + stat_summary_bin(binwidth=3, geom="bar")
assert p == "setting_binwidth"

0 comments on commit 7a25a92

Please sign in to comment.