-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
update_xaxes(categoryorder="total descending") does not work correctly on px.histogram #2350
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
Comments
I have the same issue. |
I see this same issue with histograms, and switching to bar fixes it. I would love for it to be fixed so I can move back to the simplicity of histograms. plotly: 4.11.0 |
Are folks who are encountering this bug running JupyterLab? If so, please note that the version of the If this is happening in a "classic" Jupyter Notebook or is happening in JupyterLab with an up-to-date extension then there is definitely something to fix here. Here is a Javascript-only version of the figure produced by this Python call: https://codepen.io/nicolaskruchten/pen/ExyWMZj ... if someone who is seeing this issue can please click on that link and tell me if things are rendering in or out of order (in the same browser/on the same machine as they're seeing the problem), that might help narrow down the possibilities! Note: the expected order is BAFEDC |
Hello @nicolaskruchten, I just tested on:
and the problem was there on both. However, your codepen looks fine. |
@nicolaskruchten I'm testing in a Dash App and with Terminal with same result. I'm working with data in this attach file ( test_dataframe.txt ) and running the following exmeple : col = ['lib','type','year','sup']
# Get data with attach file
df = pd.DataFrame(data, columns=col)
fig1 = px.histogram(df, x='year', y='sup', color='type').update_xaxes(type="category", categoryorder="total descending")
fig1.show()
fig2 = px.histogram(df, x='lib', y='sup', color='type').update_xaxes(type="category", categoryorder="total descending")
fig2.show() fig1 is always displaying in the right order and fig2 always displaying in the wrong order |
I really can't guess a logic that would generate that order...! |
When I create a color by histogram, it never comes out correctly, and like @Kerybas I can't figure out how it's ordering things. Even if it acts up with more than one color bin, if I turn off all colors but one, it orders properly again. If I turn even one color back on though, it goes back to the really odd ordering. |
Yes I am ;) |
I am also having this issue, but with px.bar rather than px.histogram
|
OK, we've got a fix in the underlying JS engine, which will become available with version |
I've updated to plotly 4.13 today, and I'm still seeing the odd ordering behavior with px.histogram. Has anyone else seen this fixed updating to 4.13? |
Hmm ok, maybe there's more than one problem here :) @jframe-fid can you share some simple code that shows this problem with v4.13 ? |
Oh, sorry, no the problem is simply that the fix for this got bumped to 4.14 (next week) but I didn't update my comment, sorry! |
@nicolaskruchten Did this fix get bumped again? I updated plotly and am still having this issue. |
I released Plotly.py 4.14 this morning and it includes this fix. Note that if you're using JupyterLab you'll need to update your extensions, and if you're using VSCode Python you'll need to wait for the vscode-jupyter extension to incorporate Plotly.js 1.58.1 in a release (which should happen next month). |
Hello,
When using
update_xaxes(categoryorder="total descending")
on a histogram, I expect the bars to be reordered by size.The following example, tested in a Notebook, will not work according to my expectation:
Note that the behavior is unclear to me. In certain condition, the order might be correct. For instance, if you change the last row to
['E','down']
, then the order of the plot is correct.In any case, I would expect the same result than the following:
The text was updated successfully, but these errors were encountered: