简体   繁体   中英

How to get the exact shrink value when customizing arrow styles in annotate

When willing to use customized arrow styles in matplotlib one can do the approach explained in this answer . But there is still an issue when shrinkA or shrinkB are specified.

I thought of a way to calculate these values using matplotlib functions, but without success, doing:

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 )

But nothing happens with path when I do that... any suggestions?

The approach was quite correct, it seems that shrinkA and shrinkB should be given in a ratio value between 0. and 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 )

To get the new values for orig and target :

neworig, newtarget = path.vertices

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM