9.10 Sankey Diagrams (cont.)
We’ll build the diagram using the
sankeyNetworkfunction in thenetworkD3package.Sankey diagrams created with the
networkD3package are notggplot2graphs, so they can not be modified withggplot2functions.
p <- sankeyNetwork(Links = Energy$links,
Nodes = Energy$nodes,
Source = "source",
Target = "target",
Value = "value",
NodeID = "name",
units = "TWh", #optional unit names for popups
fontSize = 12,
nodeWidth = 30)
pFollowing the flow from left to right, energy supplies are on the left and energy demands are on the right.
The graph is interactive so you are able to highlight nodes and drag them to new positions.