这是因为
秩序
数据帧中的用户。如果你仔细看你的图表,箭头总是指向
U
到
V
哪里
U < V
(
就身体位置而言
). 实际上,networkx使用
FancyArrowPatch(start, end, ...)
在引擎盖下制作箭头,如本例所示:
import matplotlib.pyplot as plt
from matplotlib.patches import FancyArrowPatch
fig, ax = plt.subplots(figsize=(6, 1))
ax.add_patch(
FancyArrowPatch((0.2, 0.5), (0.8, 0.5), mutation_scale=30, arrowstyle="-|>")
)
你想要的是
DiGraph
,箭头应该与之配合使用:
DG = nx.from_pandas_edgelist(df, "source", "sink", create_using=nx.DiGraph)
nx.draw_networkx(
DG,
nx.spring_layout(DG, seed=0),
node_color="orange",
edgecolors="k",
arrowsize=20,
)