让我们使用 FancyArrowPatch 在两个散点之间绘制一个箭头:
import matplotlib.pyplot as plt
import matplotlib as mpl
fig, ax = plt.subplots()
points = ax.scatter([0,1],[0,1], marker='o', s=300)
arrow = mpl.patches.FancyArrowPatch((0,0), (1,1), arrowstyle='-|>', mutation_scale=20)
ax.add_patch(arrow)
fig.show()
Looks OK
现在,让我们使用 PatchCollection 执行相同的绘图
import matplotlib.pyplot as plt
import matplotlib as mpl
fig, ax = plt.subplots()
points = ax.scatter([0,1],[0,1], marker='o', s=300)
arrow = mpl.patches.FancyArrowPatch((0,0), (1,1), arrowstyle='-|>', mutation_scale=20)
col = mpl.collections.PatchCollection([arrow])
ax.add_collection(col)
fig.show()
Could someone clarify what's happening?