Uh oh!
There was an error while loading. Please reload this page.
Fix selection of histograms with multiple traces - #2771
Conversation
meffmadd
commented
Sep 25, 2020
Are there any updates on this issue, @nicolaskruchten, @alexcjohnson and/or @jonmmease? In the meantime I also implemented sorting for each trace individually, however, this comes with a performance penalty so let me know if this is necessary for multiple traces. |
nicolaskruchten
commented
Nov 19, 2020
@jonmmease if you have a sec to look at this one I'd appreciate it :) |
jonmmease
commented
Nov 19, 2020
Not sorting the indices is fine. This looks good to me. Thanks, @meffmadd! |
meffmadd
commented
Dec 7, 2020
Thank you for reviewing the changes! I never pushed the version where the indices are sorted so the PR could be merged. |
meffmadd
commented
Mar 14, 2021
Hey @nicolaskruchten, I think this PR fell through the cracks but as far as I understand it, it was approved and could be merged immediately without causing problems. It would really help my project to have this functionality. Thanks! |
nicolaskruchten
commented
Mar 19, 2021
Indeed, we've not done a good job of pushing this PR along, and I apologize. The next version of Plotly.py will be v5.0 and I expect it will come out in about a month, and I'll try to get this merged and QA'ed for that release. |
meffmadd
commented
Mar 20, 2021
Thank you very much and no problem! I was busy either way the last couple of months but recently found the time to work on my stuff again. |
jonmmease
commented
Apr 23, 2021
Finally merging this, now that we're pulling version 5 changes into master. Thanks again @meffmadd! |
meffmadd
commented
Apr 27, 2021
Thanks, always happy to contribute! |
This change addresses the selection behaviour of histograms with more than one trace and fixes a bug introduced in my last change #2711.
In the previous change, the point_indexes were sorted before being returned. This is not a problem when there is only one trace, however, with multiple traces, the indices of the values get mixed and result in incorrect behaviour.
So for example consider two traces with a random distribution and both traces are being selected. Firstly, all the indices are combined into one large array with the corresponding trace_indices [0,0,…,0,0,1,1 …,1,1].
Then the index-array is sorted and all the indices get reordered while the trace information is unchanged, which causes indices being assigned to the incorrect traces later on.
A quick solution is not sorting the array, which results in correct behaviour. This has the effect that the results are also not sorted in Python in each trace. Please let me know if this is an issue.