Skip to content

Seaborn should respect categorical order when sorting pd.Categorical objects #361

Closed
@shoyer

Description

@shoyer

For example, this adaption of the "Grouped boxplots" example should work (if using pandas 0.15 or higher) even without specifying x_order:

import seaborn as sns
sns.set(style="ticks")

tips = sns.load_dataset("tips")
days = ["Thur", "Fri", "Sat", "Sun"]
tips['days'] = pd.Categorical(tips['day'], days)

g = sns.factorplot("day", "total_bill", "sex", tips, kind="box",
                   palette="PRGn", aspect=1.25)
g.despine(offset=10, trim=True)
g.set_axis_labels("Day", "Total Bill")

If you using a pandas method to do the sorting, then this is a pandas bug.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions