Visualizations Sankey
Animation
PlotAPI Sankey supports animations - both for interactions and for nice introductions to your visualisation.
Sample data
Let's import PlotAPI and load our sample data.
from plotapi import Sankey
links = [
{"source":"Group A", "target":"Rank 1", "value": 1000},
{"source":"Group B", "target":"Rank 1", "value": 300},
{"source":"Group B", "target":"Rank 2", "value": 600},
{"source":"Group B", "target":"Rank 3", "value": 400},
{"source":"Rank 1", "target":"Club A", "value": 700},
{"source":"Rank 1", "target":"Club B", "value": 400},
{"source":"Rank 1", "target":"Club C", "value": 200},
{"source":"Rank 2", "target":"Club B", "value": 200},
{"source":"Rank 2", "target":"Club C", "value": 400},
{"source":"Rank 3", "target":"Withdrawn", "value": 400},
{"source":"Club A", "target":"The Most Amazing Prize", "value": 500},
]
Demonstration
Animations can be controlled with the following parameters:
-
animated_intro
- If set toTrue
, will play an animation when the visualisaiton is loaded. This works nicely when paired with the.to_mp4()
end-point to create a video. -
animated_duration
- The duration of the intro animation in milliseconds. -
animated_links_speed
- The duration of the animation when traversing each link when mousing over a node. -
animated_hide_speed
- The duration of the animation when moving the mouse out of a node.
Let's try both approaches.
Animated interactions and intro
Interact with the visualization to see the new animation speed.
Sankey(
links,
animated_intro=True,
animated_duration=5000,
animated_links_speed=3000,
animated_hide_speed=2000,
).show()
Animated intro
Sankey(
links,
animated_intro=True,
animated_duration=5000,
animated_links_speed=3000,
animated_hide_speed=2000,
).show_mp4()