Sankey diagram


A Sankey Diagram is a visualisation technique that allows to display flows. Several entities (nodes) are represented by rectangles or text. Their links are represented with arrows or arcs that have a width proportional to the importance of the flow.

Plotly logoSankey diagram with Plotly

Plotly is an awesome Python library for interactive data visualization. It is most probably the best tool to create a Sankey Diagram. Its Sankey() function handles most of the business logic for you, allowing to get a figure in a couple of lines of code.

The examples below should quickly get you started with this minimal starting example. They then describes the most common of type of customization you probably want to apply to your figure to make it appealing.

Matplotlib logoSankey diagram with Matplotlib

The matplotlib library offers a Sankey() function that also allows to build sankey diagrams. It is a bit limited in my opinion, since it only allows to visualize flows passing through one unique group as shown in the example below.

The example below comes from the official doc. Have a look to the code .

Basic Sankey diagram with Matplotlib

Contact

👋 This document is a work by Yan Holtz. Any feedback is highly encouraged. You can fill an issue on Github, drop me a message onTwitter, or send an email pasting yan.holtz.data with gmail.com.

Violin

Density

Histogram

Boxplot

Ridgeline

Scatterplot

Heatmap

Correlogram

Bubble

Connected Scatter

2D Density

Barplot

Spider / Radar

Wordcloud

Parallel

Lollipop

Circular Barplot

Treemap

Venn Diagram

Donut

Pie Chart

Dendrogram

Circular Packing

Line chart

Area chart

Stacked Area

Streamgraph

Map

Choropleth

Hexbin

Cartogram

Connection

Bubble

Chord Diagram

Network

Sankey

Arc Diagram

Edge Bundling

Colors

Interactivity

Animation with python

Animation

Cheat sheets

Caveats

3D