如何在annotate中自定义箭头样式时获得精确的收缩值



当愿意在matplotlib中使用自定义箭头样式时,可以使用本答案中解释的方法。但是,当指定shrinkAshrinkB时,仍然存在问题。

我想到了一种方法来计算这些值使用matplotlib函数,但没有成功,做:

import matplotlib.patches as patches
orig = (1.1,2.)
target = (1.1,3.)
shrinkA = 10. # given in points
shrinkB = 0.
b = patches.ConnectionStyle('arc')
path = b.connect( orig, target )
path = b._shrink( path, shrinkA, shrinkB )

但是当我这样做时,path没有发生任何事情…有什么建议吗?

这种方法是非常正确的,似乎shrinkAshrinkB应该以0.1.之间的比率值给出:

orig =   (1.1,2.)
target = (1.1,7.)
shrinkA = 0.1 # given in points
shrinkB = 0.1
b = patches.ConnectionStyle('Arc')
path = b.connect( orig, target )
path = b._shrink( path, shrinkA, shrinkB )

获取origtarget的新值:

neworig, newtarget = path.vertices

最新更新