Python networkx:如何在粗线上获得非圆形箭头?

问题描述

我正在使用 networkx 在 Python 中绘制有向图。我使用不同宽度的边缘来突出重量。不幸的是,箭头是圆形的,看起来很奇怪。我想为看起来像细线箭头的缩放版本的粗线绘制非圆形箭头。

directed graph with weird fat arrows

import networkx as nx
import matplotlib.pyplot as plt
import numpy

G=nx.DiGraph()
stake = [
    [0,1,3],[3,1],[0,[1,3,0]
    ]
maxS = max(max(stake))
stake1d = numpy.concatenate(stake)
minS = min(stake1d[numpy.nonzero(stake1d)])
minLineWeight = 1
maxLineWeight = 10

for x in range(len(stake)):
    for y in range(x):
        if(stake[x][y] > 0):
            weight = (stake[x][y] - minS) / (maxS - minS) * (maxLineWeight - minLineWeight) + minLineWeight
            G.add_edge(x,y,weight=weight,color='r')

for x in range(len(stake)):
    for y in [i for i in range(len(stake))][-(len(stake)-x):]:
        if(stake[x][y] > 0):
            weight = (stake[x][y] - minS) / (maxS - minS) * (maxLineWeight - minLineWeight) + minLineWeight
            G.add_edge(x,color='b')

weights=list(nx.get_edge_attributes(G,'weight').values())
colors=list(nx.get_edge_attributes(G,'color').values())
pos = nx.shell_layout(G)
nx.draw(
    G,pos=pos,width=weights,edge_color=colors,with_labels=True,arrows=True,connectionstyle='arc3',arrowstyle='->'
)  
plt.show()

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)