#220 Sankey diagram with Matplotlib



The Matplotlib library has a module that allows to make basic Sankey Diagrams. This is an example coming from the corresponding documentation where you will find more examples of this type.


I strongly advise you to have a look to the Sankey section of the gallery to see other possibilities, notably using the ipysankeywidget library.



# Libraries
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.sankey import Sankey

# basic sankey chart
Sankey(flows=[0.25, 0.15, 0.60, -0.20, -0.15, -0.05, -0.50, -0.10], labels=['', '', '', 'First', 'Second', 'Third', 'Fourth', 'Fifth'], orientations=[-1, 1, 0, 1, 1, 1, 0,-1]).finish()
plt.title("Sankey diagram with default settings")

Leave a Reply

Your email address will not be published.