diff --git a/doc/changelog.qmd b/doc/changelog.qmd index 4102dc538..33c984c17 100644 --- a/doc/changelog.qmd +++ b/doc/changelog.qmd @@ -10,6 +10,9 @@ title: Changelog - Fix bug in [](:class:`~plotnine.stat_smooth`) where you could not set the family when using a `glm`. ({{< issue 769 >}}) +- Fix bug in [](:class:`~plotnine.position_dodge2`) the widths of the dodged + objects were mixed up. ({{< issue 772 >}}) + ## v0.13.4 (2024-04-03) diff --git a/plotnine/positions/position_dodge2.py b/plotnine/positions/position_dodge2.py index fbc70fdf8..d82d94520 100644 --- a/plotnine/positions/position_dodge2.py +++ b/plotnine/positions/position_dodge2.py @@ -117,7 +117,7 @@ def strategy(data, params): # If n is None, preserve total widths of elements at # each position by dividing widths by the number of # elements at that position - n = data["xid"].value_counts().to_numpy() + n = data["xid"].value_counts(sort=False).to_numpy() n = n[data.loc[:, "xid"] - 1] data["new_width"] = (data["xmax"] - data["xmin"]) / n else: