Sankey Diagram





A Sankey diagram allows to study flows. Entities (nodes) are represented by rectangles or text. Arrows or arcs are used to show flows between them. In R, the networkD3 package is the best way to build them

Step by step

The networkD3 package allows to visualize networks using several kinds of viz. One of its function makes stunning Sankey diagrams as shown below. Follow the steps below to get the basics and learn how to customize your Sankey Diagram.





Interactivity

The networkD3 package is an htmlwidget: it automatically builds interactive charts. Check the chart below: you can drag nodes and hover links for more informagtion. If for some reason you need to export it to png or pdf, it is possible thanks to the webshot package.

Note: The example below comes directly from the networkD3 documentation.

How to export to .png Chart code





Alluvial diagram

An alluvial chart is a variation of the sankey plot. It visualizes frequency distributions over time or frequency tables involving several categorical variables. In R, 2 packages exist to build an alluvial diagram: alluvial and ggalluvial

Related chart types


Chord diagram
Network
Sankey
Arc diagram
Edge bundling