VESankey

class iesve.VESankey(ordering: str = 'given')

Bases: object


add_column_names(column_names: list[str]) None

Adds names for the columns in the diagram. Used for labelling the diagram.


add_connections(connections: list[tuple[str, str, float]]) None

Adds connections between nodes in the network. Each entry in the connections list should be a tuple containing the source node name (string), destination node name (string) and the connection weight (real).

  • Tuple is ([(source, destination, weight)])

  • source -> string

  • destination -> string

  • weight -> real

Nodes should already have been added through either iesve.VESankey.add_node_names_in_order() or iesve.VESankey.add_node_columns()


add_node_colours(colours: dict[str, tuple[int, int, int]]) None

Sets the colour each node should be generated with. colours is a dictionary of {string : tuple}, where the string is the name of the node, and the tuple holds the RGB values for the colour of that node.


add_node_columns(node_columns: dict[str, int]) None

Adds nodes to the diagram, in the specified column index.

nodeColumns is a dictionary, where each entry is {node_name (str) : column_index (int)}.


add_node_names_in_order(names: list[str]) None

Adds names for the nodes to be used as labels in the diagram. Python Dictionaries do not retain ordering of items; this function can be used to ensure nodes are added to the diagram in the order they appear in the list. Can be useful to control positions of nodes in the final diagram.

iesve.VESankey.add_node_columns() still needs to be called, regardless of whether iesve.VESankey.add_node_names_in_order() is called or not.


clear() None

Clears all added data from the sankey generator. Necessary if you wish to reuse the same VESankey object to generate multiple different sankey diagrams.


generate_sankey() None

Once all nodes and connections have been added, calling generate_sankey will generate an in-memory representation of the sankey diagram, ready for exporting.


recommended_ratio() float

Returns the recommended ratio for the connection weight:line width rations that will be used if no ratio is specified through iesve.VESankey.set_weight_width_ratio().


save_png(filename: str) None

After generate_sankey has been called, save_png will export the sankey diagram as a .png file.


save_svg(filename: str) None

After generate_sankey has been called, save_svg will export the sankey diagram as a .svg file.


set_title(title: str) None

Sets the title of the diagram.


set_units_str(unit: str) None

Sets the string to be used as a legend for representing the units the connection weights are in.


set_weight_width_ratio(ratio: float) None

Sets the weight:line width ratio the diagram should use. Can be used to somewhat control how thick the connection lines should be with vastly differing weights.