The Sankey diagram is a way of visualizing the flow of data. A Sankey diagram consists of three sets of elements: the nodes, the links, and the instructions which determine their positions. The node is wherever the lines change direction. The second element is the edge, that connect the nodes together. These links have a value associated with them, which is represented by the thickness of the link.
Moreover, instructions specify where the nodes should appear in relation to each other. There are two strategies for positioning the nodes: 1 - give specific coordinates: the position of the nodes reflects places in countries such as Italy, UK, and Switzerland. 2 - he nodes can be placed automatically using an algorithm. Most commonly, a variant of the force-directed graph layout algorithm is used.
library(networkD3)
sankeyNetwork(Links = Energy$links, Nodes = Energy$nodes, Source = "source",
Target = "target", Value = "value", NodeID = "name",
units = "TWh", fontSize = 12, nodeWidth = 30)
The Sankey diagram is created using data from the UK’s Department of Energy & Climate Change.