python - 如何将 matplotlib.patches.FancyArrowPatch 的尾部宽度设置为零?
问题描述
有没有办法将 FancyArrowPatch 的尾部宽度设置为零?设置tail_width
关键字ArrowStyle
并没有达到预期的效果。我也不清楚这个关键字的单位实际上是什么。我在文档中找不到描述。我想可能是axes points
?
MWE:
import matplotlib.pyplot as plt
from matplotlib.patches import FancyArrowPatch
fig, ax = plt.subplots()
arrow = FancyArrowPatch(
posA=(0, 0), posB=(1, 0), fc=None, ec='#1f77b4',
arrowstyle='simple, head_width=10, head_length=10, tail_width=0.0',
)
ax.add_artist(arrow)
ax.set_xlim(-1, 2)
ax.set_ylim(-1, 1)
plt.show()
解决方案
IIUC,您可以尝试使用楔形样式来达到您想要的效果,例如
arrowstyle='wedge,tail_width=50,shrink_factor=0.5'