【发布时间】:2017-11-21 08:35:22
【问题描述】:
让我们使用 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()
看起来不错
现在,让我们使用 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()
【问题讨论】:
-
看起来这是一个已知问题(并且已经存在了一段时间):github.com/matplotlib/matplotlib/issues/2341
-
答案here 建议使用
shrinkA=0, shrinkB=0,但在你的情况下这对我不起作用。
标签: python matplotlib