Skip to content

objects.Text: Is it possible to center texts for stacked bar plot? #3429

Answered by frfeng
frfeng asked this question in Q&A
Discussion options

You must be logged in to vote

That makes sense. It works now. Thank you! For future reference below is the complete example.

from dataclasses import dataclass

import matplotlib as mpl
import numpy as np
from pandas import DataFrame
from seaborn._core.groupby import GroupBy
from seaborn._core.moves import Move
from seaborn._core.typing import Default

@dataclass
class MiddleStack(Move):
    def _stack(self, df, orient):

        if df["baseline"].nunique() > 1:
            err = "Stack move cannot be used when baselines are already heterogeneous"
            raise RuntimeError(err)

        other = {"x": "y", "y": "x"}[orient]
        stacked_lengths = (df[other] - df["baseline"]).dropna().cumsum()
        offsets = s…

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@frfeng
Comment options

@thuiop
Comment options

@frfeng
Comment options

Answer selected by frfeng
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants