Skip to content

allow users to sort nodes in Sankey plot #4373

Closed

Description

@Mahdis-z

Would be very useful to add a feature to enable users to sort nodes based on their desired output.

Activity

  1. etpinard commented on Nov 26, 2019

    @etpinard
    Contributor

    @antoinerg can you confirm that the current sankey implementation does not allow sorting nodes?

  2. antoinerg commented on Nov 26, 2019

    @antoinerg
    Contributor

    @etpinard I confirm we don't currently allow sorting nodes. However, it seems like underlying engines support it:

  3. 1kastner commented on Sep 27, 2021

    @1kastner

    It would be great to have this feature!

  4. hohuyhoangg commented on Aug 31, 2023

    @hohuyhoangg

    @archmoj I really need this feature.

  5. adamreeve commented on Jan 7, 2024

    @adamreeve
    Contributor

    I'm also interested in this feature, and had a look into implementing this. The main challenge is that the plotly fork of d3-sankey (https://github.com/plotly/d3-sankey) is quite old and doesn't include the nodeSort feature, so either that feature needs to be ported to the plotly fork, or recent changes from upstream need to be merged into the fork. plotly/d3-sankey-circular would also need updating.

    Then you can simply call sankey.nodeSort(null) so that the order of nodes is based on the order in the input array rather than letting the layout reorder them.

  6. scodesido-at-proton commented on Mar 7, 2024

    @scodesido-at-proton

    Pinging here, this feature would be really useful for reproducibility. I understand we can specify x/y coordinates, but if I have to do a nontrivial layout like that, I may as well paint traces myself without using Plotly. It is a bit weird that this is supported by the underlying d3 but plotly cannot expose. This kind of issue has been open for years now...

  7. self-assigned this
    on Jul 8, 2024
  8. removed their assignment
    on Aug 2, 2024
  9. changed the title [-]Sankey: sort nodes [/-] [+]allow users to sort nodes in Sankey plot[/+] on Aug 9, 2024
  10. Nats1rt commented on Feb 28, 2025

    @Nats1rt

    Would still be useful. It makes the use of Sankey diagrams combined to sliders rather irrelevant, as position of the nodes might change at each step...

  11. erklem commented on Dec 11, 2025

    @erklem

    I agree. This would be a great feature! There have been similar requests (e.g. plotly/plotly.py#960) on the python repo, and the plotly team has redirected people to this plotly.js repo for this feature.

  12. added this to the v4.0.0 milestone on Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions