Controlling Sankey diagram connections : <p>I'm trying to control which flows connect to each other using the Matplotlib Sankey diagram. I'm modifying the basic two systems example.</p>

<p>I think my confusion comes down to misunderstanding what this actually means:</p>

<blockquote>
  <p>Notice that only one connection is specified, but the systems form a circuit since: (1) the lengths of the paths are justified and (2) the orientation and ordering of the flows is mirrored.</p>
</blockquote>

<p>I've made a toy example that uses a single data set and then modifies it for the second systems to make sure that the numbers all match up.</p>

<pre><code>import numpy as np
import matplotlib.pyplot as plt

from matplotlib.sankey import Sankey

plt.rcParams["figure.figsize"] = (15,10)


system_1 = [
    {"label": "1st",  "value":  2.00, "orientation":  0},
    {"label": "2nd",  "value":  0.15, "orientation": -1},
    {"label": "3rd",  "value":  0.60, "orientation": -1},
    {"label": "4th",  "value": -0.10, "orientation": -1},
    {"label": "5th",  "value":  0.25, "orientation": -1},
    {"label": "6th",  "value":  0.25, "orientation": -1},
    {"label": "7th",  "value":  0.25, "orientation": -1},
    {"label": "8th",  "value":  0.25, "orientation": -1},
    {"label": "9th",  "value":  0.25, "orientation": -1}
]

system_2 = system_1[:4]
system_2.append({"label": "new",  "value":  -0.25, "orientation": 1})


fig = plt.figure()
ax = fig.add_subplot(1, 1, 1, xticks=[], yticks=[], title="Where are all my cows?")
flows  = [x["value"] for x in system_1]
labels = [x["label"] for x in system_1]
orientations=[x["orientation"] for x in system_1]
sankey = Sankey(ax=ax, unit="cow")
sankey.add(flows=flows, 
           labels=labels,
           label='one',
           orientations=orientations)

sankey.add(flows=[-x["value"] for x in system_2], 
           labels=[x["label"] for x in system_2],
           label='two',
           orientations=[-x["orientation"] for x in system_2], 
           prior=0, 
           connect= (0,0)
          )

diagrams = sankey.finish()
diagrams[-1].patch.set_hatch('/')
plt.legend(loc='best')


plt.show()
</code></pre>

<p>This gives me:</p>

<p><a href="https://i.stack.imgur.com/3MYVq.png" rel="noreferrer"><img src="https://i.stack.imgur.com/3MYVq.png" alt="A sankey diagram that doesn&#39;t really work"></a></p>

<p>It <em>should</em> join up the flows with matching labels.</p>

<p>I've read <a href="https://stackoverflow.com/questions/20425103/connecting-two-sankey-diagrams-in-matplotlib">this</a> and <a href="https://stackoverflow.com/questions/26677690/connecting-flows-in-matplotlib-sankey-diagram">this</a> but they aren't helping me understand what is actually happening.</p>
