I am trying to make a slightly complex sankey diagram using matplotlib, It is supposed to be dynamical in the sense that I should be able to change the values of the flows and that all connections should stay connected. This means that I cannot manually adjust the path-lengths like suggested in this example. To familiarise myself with the explicit and implicit connections I tried to continue building from this example of two systems connected together with only one explicit connection. With this example you can change the values of the flows and things stay connected correctly. So I tried to add a fourth system that goes from system 1 to 2, but I can't seem to get the implicit connection to work. Please see the code and output below.
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.sankey import Sankey
import matplotlib as mpl
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1, xticks=[], yticks=[], title="Two Systems")
flows = [0.3, 0.1, 0.40, -0.20, -0.4, -0.2]
sankey = Sankey(ax=ax, unit=None, radius=0.15, )
sankey.add(flows=flows, label='one',
orientations=[-1, 1, 0, 1, 0, -1])
sankey.add(flows=[-0.3, 0.2, 0.1], label='two',
orientations=[-1, -1, 0], prior=0, connect=(0, 0))
sankey.add(flows=[-0.1,-0.1,0.2], label='three',
orientations=[1,0,1], prior=0,connect=(1, 0))
sankey.add(flows=[0.4,-0.1,-0.3], label='four',
orientations=[-1,-1,0], prior=0,connect=(4, 0))
diagrams = sankey.finish()
diagrams[-1].patch.set_hatch('/')
plt.legend(loc='best')
plt.show()
print "Test"
Any hints or tips to make a dynamic sankey diagram with several connected systems would be greatly appreciated.