Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing move order when order is set in scale #3150

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions seaborn/_core/moves.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down