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

Bar plot's category_orders not work, no matter if facet_col used #3645

Closed
kk120120 opened this issue Mar 25, 2022 · 5 comments
Closed

Bar plot's category_orders not work, no matter if facet_col used #3645

kk120120 opened this issue Mar 25, 2022 · 5 comments

Comments

@kk120120
Copy link

Hi
This issue is linked to still opened issue #3033 and closed issue #2084.
I found a note in below which said bug had been fixed. but in my verion 5.53, it happen again.
@emmanuelle not sure if i misunderstand the info below:

added this to the v4.5.0 milestone on 16 Jan 2020

https://community.plotly.com/t/python-plotly-express-facet-col-facet-row-order-categories/33693
#2084

any alternative ways? or could fix it again.

Thanks!

demo_PLOTS

Source code and demo data are here:

dt = pd.read_csv('e:/demo.csv')
# if use facet_col, category_orders will be not effected. just buy maybe first read value in x axes. not by high to low or low to high 
# if not use facet_col, only one plot, no problem. 
# also test without facet_col, the category_orders setting seems no influence on plot.

cat_ord = dt.groupby(by='area').agg({'numbers':'sum'}).sort_values('numbers', ascending=True).index
fig = px.bar(dt.reset_index(), x='area', y='numbers', color='date',
             facet_col='type',
             category_orders={cat_ord.name:cat_ord.to_list()},
             barmode='stack',
            ).update_xaxes(categoryorder='total descending')
fig.update_layout(height=500, width=1200, legend_traceorder="reversed")
fig.show()

demo.csv

Plotly version info

system: Win10

Name: plotly
Version: 5.3.1
Summary: An open-source, interactive data visualization library for Python
Home-page: https://plotly.com/python/
Author: Chris P
Author-email: chris@plot.ly
License: MIT
Location: d:\wpy64-3970b3\python-3.9.7.amd64\lib\site-packages
Requires: six, tenacity
Required-by:

@jlondonobo
Copy link

I'm experiencing the same issue on Plotly 5.7.0

@estelle-gallardo
Copy link

Hello. It doesn' work for me either
'5.18.0'

fig = px.bar(x=bins, y=counts, labels={'x':'Age', 'y':'count'})
fig.update_xaxes(categoryorder="total descending")
fig.show()

In ascending order :(

@Coding-with-Adam
Copy link
Contributor

hi @estelle-gallardo can you please provide the whole code and data as a minimal reproducible example?
I'd like to reproduce the same error you get on my computer.

@gvwilson
Copy link
Contributor

Hi - we are tidying up stale issues and PRs in Plotly's public repositories so that we can focus on things that are still important to our community. Since this one has been sitting for a while, I'm going to close it; if it is still a concern, please add a comment letting us know what recent version of our software you've checked it with so that I can reopen it and add it to our backlog. If you'd like to submit a PR, we'd be happy to prioritize a review, and if it's a request for tech support, please post in our community forum. Thank you - @gvwilson

@estelle-gallardo
Copy link

estelle-gallardo commented Jul 12, 2024 via email

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

5 participants