Arrow Pointing To Edge Of Marker Independently From Markers Size
This is goes in the same direction as this question. I want to point an arrow from one scatter point to another, so that the arrow head lies next to edge of the marker. Like in the
Solution 1:
The shrinkA/shrinkB arguments of FancyArrowPatch expect their argument in units of points. Points is also the unit of linewidth or markersize. For a scatter plot, the size argument s is the square of the markersize.
So given the size of the scatter plot, s=size, the shrink is calculated by taking the squareroot and dividing by 2 (because you want to shrink the arrow by the radius, not the diameter).
shrink = math.sqrt(size)/2.
Example:
import matplotlib.pyplotas plt
import matplotlib as mpl
import math
fig, ax = plt.subplots()
size = 1000
radius = math.sqrt(size)/2.
points = ax.scatter([0,1], [0,1], s=size)
arrow = mpl.patches.FancyArrowPatch(posA=(0,0), posB=(1,1),
arrowstyle='-|>', mutation_scale=20,
shrinkA=radius, shrinkB=radius)
ax.add_patch(arrow)
plt.show()

Post a Comment for "Arrow Pointing To Edge Of Marker Independently From Markers Size"