How to do a Sankey Plot in Python

Mattia Cinelli
Analytics Vidhya
Published in
4 min readMay 3, 2020

--

If you have been more than five seconds on r/dataisbeautiful/, you will have probably encountered a Sankey plot. Everyone uses it to track their expenses, job searching and every other multi-step processes.
Indeed, it is very suitable to visualize the progression of events and their outcome. And in my opinion, they look great!

Therefore, let’s see how to do in Python:

In matplotlib

Personally, in matplotlib they look awful:

The above plot is probably closer to the original concept of a Sankey plot (originally invented in 1898), but it is not something I would use in a publication.

The other solution is to use the library Plotly.

In Plotly

Therefore, without further ado:

Plotly is an interactive visualisation library. Created to work on Jupyter and it allows, not only to see the plots you create, but to interact with them and to see every details of the figures.

--

--