From 692a9ec1ed5d590fa257cb7c3a418ef8e1046fef Mon Sep 17 00:00:00 2001 From: thuiop Date: Sat, 19 Nov 2022 22:33:57 +0100 Subject: [PATCH] Changing move order when order is set in scale --- seaborn/_core/moves.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/seaborn/_core/moves.py b/seaborn/_core/moves.py index 179926e717..584cdcf0a9 100644 --- a/seaborn/_core/moves.py +++ b/seaborn/_core/moves.py @@ -1,6 +1,7 @@ from __future__ import annotations from dataclasses import dataclass from typing import ClassVar, Callable, Optional, Union, cast +from functools import partial import numpy as np from pandas import DataFrame @@ -162,11 +163,11 @@ class Stack(Move): """ # TODO center? (or should this be a different move, eg. Stream()) - def _stack(self, df, orient): + def _stack(self, df, orient, order=None): # TODO should stack do something with ymin/ymax style marks? # Should there be an upstream conversion to baseline/height parameterization? - + df = GroupBy(order).apply(df, lambda x: x) if df["baseline"].nunique() > 1: err = "Stack move cannot be used when baselines are already heterogeneous" raise RuntimeError(err) @@ -187,7 +188,9 @@ def __call__( # TODO where to ensure that other semantic variables are sorted properly? # TODO why are we not using the passed in groupby here? groupers = ["col", "row", orient] - return GroupBy(groupers).apply(data, self._stack, orient) + return GroupBy(groupers).apply(data, + partial(self._stack, order=groupby.order), + orient) @dataclass