plotly.py icon indicating copy to clipboard operation
plotly.py copied to clipboard

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

Open kk120120 opened this issue 3 years ago • 3 comments

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 https://github.com/plotly/plotly.py/issues/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: [email protected] License: MIT Location: d:\wpy64-3970b3\python-3.9.7.amd64\lib\site-packages Requires: six, tenacity Required-by:

kk120120 avatar Mar 25 '22 09:03 kk120120

I'm experiencing the same issue on Plotly 5.7.0

jlondonobo avatar Apr 22 '22 21:04 jlondonobo

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 :(

estelle-gallardo avatar Feb 16 '24 12:02 estelle-gallardo

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.

Coding-with-Adam avatar Feb 20 '24 17:02 Coding-with-Adam

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

gvwilson avatar Jul 11 '24 22:07 gvwilson

Hello, sorry for the late reply. I didnt check the problem again as I found another solution. I think I provided you with the code for the problem but I don't have it any more as I changed it. Thank you for your kind help Regards

On Fri, 12 Jul 2024 at 00:23, Greg Wilson @.***> wrote:

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 https://github.com/gvwilson

— Reply to this email directly, view it on GitHub https://github.com/plotly/plotly.py/issues/3645#issuecomment-2224054596, or unsubscribe https://github.com/notifications/unsubscribe-auth/BCP7NLI2MW473DD3VIW4NHDZL4AXVAVCNFSM5RTUMZOKU5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TEMRSGQYDKNBVHE3A . You are receiving this because you were mentioned.Message ID: @.***>

estelle-gallardo avatar Jul 12 '24 13:07 estelle-gallardo