ricklupton / floweaver

View flow data as Sankey diagrams
https://floweaver.readthedocs.io
MIT License
449 stars 89 forks source link

plotting multiple diagrams #125

Open JFA-CT opened 2 years ago

JFA-CT commented 2 years ago

Hi there, Is there any way to plot two sankey diagrams in the same html? I'm trying to do a visual comparison so that the relative size of the lines are proportional (and thus both sankeys are comparable but still separate) to each other? Thanks for any tips.

ricklupton commented 2 years ago

Hi @JFA-CT assuming you are using ipysankeywidget to show the Sankey diagrams in a Jupyter notebook, you can set the scale of the diagrams by setting the SankeyWidget's scale attribute.

Something like

scale = 0.2  # SVG units per data unit
w = weave(...).to_widget()
w.scale = scale
w  # at end of a cell it gets displayed (or you can use IPython display(w) explicitly)

See example here (if you can ignore the part which is about setting custom node positions, and see where the scale is set) https://nbviewer.org/github/ricklupton/ipysankeywidget/blob/master/examples/More%20examples.ipynb#Custom-layout