如何在Matplotlib中获得一个打开和缩放的箭头

Han*_*ans 3 python matplotlib seaborn

在Seaborn的小图中,我想用箭头注释一列。现在,虽然我看到这看起来似乎有点眼光,但我还是很希望这两个箭头

  1. 有一个开放的头部(即不是一个封闭的三角形作为头部,而是两条开放线)和
  2. 扩展当我调整的身影。

我发现了两种添加箭头的matplotlib方法(arrowannotate方法),但是每种方法似乎都缺少这些功能之一。这段代码并排绘制:

import seaborn as sns

sns.plt.subplot(121)
ax = sns.barplot(("x", "y", "z"), (1, 4, 7))
# head is not open
ax.arrow(0, 5, 0., -3.5, lw=1, fill=False,
         head_length=.5, head_width=.2,
         length_includes_head=True)

sns.plt.subplot(122)
ax = sns.barplot(("x", "y", "z"), (1, 4, 7))
# head does not scale with figure
ax.annotate("", xytext=(0, 5), xy=(0, 1.5),
            arrowprops=dict(arrowstyle="->, head_length = 2, head_width = .5", lw=1))

sns.plt.show()
Run Code Online (Sandbox Code Playgroud)

左箭头的头部关闭(难看),但是当我调整图形大小时,它的缩放比例很好(因为我认为头部的大小以数据单位为单位)。右箭头的头部很好看而且很张开,但是无论图形大小如何,它始终保持相同的像素大小。因此,当数字较小时,右箭头看起来相对较大:

右箭头太大

当我将图形变大时,右箭头变小-相对-而左箭头变好了:

右箭头太小

因此,有没有一种方法可以使用开放且可缩放的箭头?