-
-
Notifications
You must be signed in to change notification settings - Fork 1
Scatter with animation_frame is plotted out of order #23
Comments
If you're using Python 2, then order is not guaranteed unfortunately and you'll have to use the |
@nicolaskruchten I am using Python 3. But for the sake of trying: how do I use category_orders? |
If you're using Python 3 then this is a bug :) Can you post a minimal reproducible example in source here please? the |
Ah, sorry, I should be clearer: if you're using Python below 3.7 (i.e. not just 2.*) then order is not guaranteed. As of Python 3.7 iterating over dict keys is guaranteed to be in insertion order |
@nicolaskruchten Then that must be it. I have Python 3.5.2 |
Thanks for that insight about Python 3.5.2 vs 3.7 I hadn't thought of that. Here is the minimal code/environment to run it https://gist.github.com/kmader/7a182744194a5330008b6e40d60aea6b and the link to just run it on mybinder: https://mybinder.org/v2/gist/kmader/7a182744194a5330008b6e40d60aea6b/master?filepath=example.ipynb As Kaggle Kernels use Python >3.5 it works fine on their site: https://www.kaggle.com/kmader/plotly-express-bug |
@nicolaskruchten So I finally decided to test the theory and installed Python 3.7.3. The out of order problem remains. The only thing that worked to fix this was using the category_orders. |
@dvduvix this is very puzzling... are you able to share a CSV of your data or some other way I could reproduce this locally? |
(also, perhaps try with v0.1.8 which just came out with a subtle change that might just shake this problem loose) |
@dvduvix |
@MengyinZhong px.scatter(data, animation_frame='frame', animation_group='col_name', category_orders={0: range(1000)}) where 0 is the column name (use quotes if your column has an actual name) and range can be replaced with the list of all the items of that particular column but in the order you want. @nicolaskruchten I cannot share the file right now, but it's just a CSV file in the following format" I will try the latest version as soon as I can |
I'm really struggling to replicate this bug on this end with Python 3.7. In fact, I'm struggling to get the frames to render out of order at all no matter what I do to the data frame :) |
@dvduvix Thank you for your reply, and I tried the solution you provided, but the timeline is still out of order, shown as below |
@MengyinZhong what version of Python and plotly_express are you using? |
OK, I've just pushed what I believe is a fix for this in version 0.2.1, such that animation frames by default now should always render in the order the values are encountered in the input data frame. Please let me know if you're still encountering issues with this latest version! |
@nicolaskruchten |
Wow, that's really bizarre. Can you share your data as well so that I can replicate this locally? What happens if you don't set |
@nicolaskruchten I got the same result without setting category_orders. Here is my data https://github.com/MengyinZhong/test/blob/master/test.csv |
OK, thanks for sharing this data! I can reproduce your problem on this end and I'll try to push out another fix shortly. I really appreciate the patience and follow-through: this makes the library better for everyone 😄 🙏 |
OK, I think I've got it for real this time! Please try v0.2.2, with or without |
Closing for now, please reopen if this happens again :) |
Hi, @nicolaskruchten , I have the same problem, the year animation frame is out of order, and I am having the same issue in my laptop and also in Kaggle notebook. Here is the link to the notebook to replicate the issue. I am using latest plotly, same as in Kaggle Notebook. Thanks! |
I tried to plot a scatter with plotly express and I got a very weird behavior
Any thoughts?
The text was updated successfully, but these errors were encountered: