You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG]: bundlecolors in parallel_categories plot (Parcats) sort numerical values out of order #7952
I have been trying to use plotly express 'parallel_categories()' function to create a parallel categories diagram from a pandas dataframe. I wanted to color code it with a continuous variable (e.g. p-value) in the dataframe, which worked. However, within each category in a dimension, were sorted in a weird way. The color scale separate into two parts with the largest and smallest values in the middle.
It was as though the values were sorted as a string representation of the value (e..g 1, 10, 11, 12 before 2, 20, 3, 4, etc.) At first I thought it has to do with my data format, but it was numerical ('float64'). The code below produce the same phenomenon. See also screenshot below.
Screenshots/Video
sorted "B_cut" for better illustration:
Steps to reproduce
The following code produced the plot in the screenshot.
Thanks for reporting @aaronbwong ! Likely something is converting the data to string and doing the comparison incorrectly. Possibly on the Plotly.js side after serialization. This might be an interesting issue for someone in the community to tackle since it's likely a small change somewhere and should be easy to test!
After tracing this through current main, I found the bug is in the bundled Plotly.js path comparator, not Plotly.py. When bundlecolors is enabled it prepends each numeric rawColor to an array, then compares the arrays with the less-than and greater-than operators. JavaScript coerces those arrays to strings, producing the reported lexicographic order (1, 10, 11, 2, ...). Plotly.py serializes both the dimension values and line colors as numeric arrays correctly, so a focused Python-side patch would be the wrong layer. I will not submit a PR here; leaving this available for a Plotly.js fix.
Activity
robertclaus commentedon Aug 3, 2026
Thanks for reporting @aaronbwong ! Likely something is converting the data to string and doing the comparison incorrectly. Possibly on the Plotly.js side after serialization. This might be an interesting issue for someone in the community to tackle since it's likely a small change somewhere and should be easy to test!
nightcityblade commentedon Aug 9, 2026
Hi, I'd like to work on this. I'll submit a PR shortly.
nightcityblade commentedon Aug 9, 2026
After tracing this through current main, I found the bug is in the bundled Plotly.js path comparator, not Plotly.py. When bundlecolors is enabled it prepends each numeric rawColor to an array, then compares the arrays with the less-than and greater-than operators. JavaScript coerces those arrays to strings, producing the reported lexicographic order (1, 10, 11, 2, ...). Plotly.py serializes both the dimension values and line colors as numeric arrays correctly, so a focused Python-side patch would be the wrong layer. I will not submit a PR here; leaving this available for a Plotly.js fix.
aaronbwong commentedon Aug 10, 2026
@robertclaus Should I post this then as an issue in Plotly.js instead?
camdecoster commentedon Aug 10, 2026
Thanks for investigating! Since this is an issue with plotly.js, we can transfer the issue.