__init__(self, ax=None, scale=1.0, unit='', format='%G', gap=0.25, radius=0.1, shoulder=0.03, offset=0.15, head_angle=100, margin=0.4, tolerance=1e-06, **kwargs)
The optional arguments listed below are applied to all subdiagrams so that there is consistent alignment and formatting.
In order to draw a complex Sankey diagram, create an instance of Sankey
by calling it without any kwargs:
sankey = Sankey()
Then add simple Sankey sub-diagrams:
sankey.add() # 1 sankey.add() # 2 #... sankey.add() # n
Finally, create the full diagram:
sankey.finish()
Or, instead, simply daisy-chain those calls:
Sankey().add().add... .add().finish()
Axes onto which the data should be plotted. If ax isn't provided, new Axes will be created.
Scaling factor for the flows. scale sizes the width of the paths in order to maintain proper layout. The same scale is applied to all subdiagrams. The value should be chosen such that the product of the scale and the sum of the inputs is approximately 1.0 (and the product of the scale and the sum of the outputs is approximately -1.0).
The physical unit associated with the flow quantities. If unit is None, then none of the quantities are labeled.
A Python number formatting string or callable used to label the flows with their quantities (i.e., a number times a unit, where the unit is given). If a format string is given, the label will be format % quantity
. If a callable is given, it will be called with quantity
as an argument.
Space between paths that break in/break away to/from the top or bottom.
Inner radius of the vertical paths.
Size of the shoulders of output arrows.
Text offset (from the dip or tip of the arrow).
Angle, in degrees, of the arrow heads (and negative of the angle of the tails).
Minimum space between Sankey outlines and the edge of the plot area.
Acceptable maximum of the magnitude of the sum of flows. The magnitude of the sum of connected flows cannot be greater than tolerance.
Any additional keyword arguments will be passed to add
, which will create the first subdiagram.
Create a new Sankey instance.
.. plot:: gallery/specialty_plots/sankey_basics.pySee :
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them