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

Seaborn Objects: Barplot bars order #3022

Closed
JanPalasek opened this issue Sep 13, 2022 · 2 comments
Closed

Seaborn Objects: Barplot bars order #3022

JanPalasek opened this issue Sep 13, 2022 · 2 comments

Comments

@JanPalasek
Copy link

Hello. I found an inconsistency between SO (Seaborn Objects) and functional API.

When having a values sorted descendingly, SO puts the first value (as ordered in pandas df) to the bottom. This problem occurs only for horizontal bar chart.

SO

image

This works differently than in the functional API.

Functional API

image

Would it be possible to have the default set as in the functional API with an option to override it? This default would work better with value_counts, since people start looking at the plot from the top-left corner, so this is the place where we want them to show the "most important" category.

@liuzj039
Copy link

Not the developer of seaborn, but I believe scale can solve this problem.

(
    so.Plot(data=freq, x='name', y='index')
    .add(so.Bar())
    .scale(y=so.Nominal(order = ['A', 'B']))
)

image

@mwaskom
Copy link
Owner

mwaskom commented Sep 13, 2022

Duplicate of #2967, thanks.

@mwaskom mwaskom closed this as completed Sep 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants