我正在使用matplotlibssankey
功能,在连接两个流时遇到问题。基本上,我只想将流连接到流的末尾。在
看起来很容易,但我还没弄明白怎么处理。在
这是截图:https://www.dropbox.com/s/2satz9ryniy958v/Sankey.png?dl=0 代码如下:
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.sankey import Sankey
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1, xticks=[], yticks=[],
title="Vereinfachtes Kraftwerksmodell")
sankey = Sankey(ax=ax, unit=None)
sankey.add(flows=[1.0, -0.3, -0.1, -0.1, -0.5],
labels=['P$el$', 'Q$ab,vd$', 'P$vl,vd$', 'P$vl,mot$', ''],
label='Laden',
orientations=[0, -1, 1, 1, 0])
sankey.add(flows=[0.5, 0.1, 0.1, -0.1, -0.1, -0.1, -0.1, -0.3], fc='#37c959',
label='Entladen',
labels=['P$mech$', 'Q$zu,ex$', 'Q$zu,rekup$', 'P$vl,tb$', 'P$vl,gen$', 'Q$ab,tb$', 'Q$ab,rekup$', 'P$nutz$'],
orientations=[0, -1, -1, 1, 1, -1, -1, 0], prior=0, connect=(4, 0))
sankey.add(flows=[-0.1, 0.1],
label='Rekuperator',
#labels=['bla'],
orientations=[1,1], prior=1, connect=(2, 0))
diagrams = sankey.finish()
diagrams[-1].patch.set_hatch('/')
plt.legend(loc='lower right')
plt.show()
有人有主意吗?
提前谢谢 绳索
我也迟到了,但有一种比担心路径长度简单得多的方法。在
向后运行路径时,方向值将反转,因此-1为向上,1为向下。在
要修复代码,只需将Rekuperator sankey代码更改为:
Producing this diagram
我想我已经太晚了,但解决方法如下: 您需要为第一个节点指定路径长度,并手动调整以匹配较小的节点。在
相关问题 更多 >
编程相关推荐