|
From: Skipper S. <jss...@gm...> - 2013-01-30 00:40:15
|
On Tue, Jan 29, 2013 at 5:11 PM, Skipper Seabold <jss...@gm...>wrote: > Say I have a marker with a known size in points and I want to draw an > arrow to this point. How can I get the ends points for the arrow? As you > can see in the below, it overlaps the markers. I want to go to the edge. I > can use shrinkA and shrinkB to do what I want, but I don't see how they're > related to the points size**.5. Or should I somehow do the transformation > using the known angle between the two points and the point itself. I don't > know how to translate a point in data coordinates and the offset it in a > certain direction by size**.5 points. Can anyone help clear this up? > > Skipper > > import matplotlib.pyplot as plt > from matplotlib.patches import FancyArrowPatch > > point1 = (138.21, 19.5) > x1, y1 = point1 > point2 = (67.0, 30.19) > x2, y2 = point2 > size = 700 > > fig, ax = plt.subplots() > ax.scatter(*zip(point1, point2), marker='o', s=size) > > # if I need to get and use the angles > dx = x2 - x1 > dy = y2 - y1 > d = np.sqrt(dx**2 + dy**2) > > arrows = FancyArrowPatch(posA=(x1, y1), posB=(x2, y2), > color = 'k', > arrowstyle="-|>", > mutation_scale=700**.5, > connectionstyle="arc3") > > ax.add_patch(arrows) > > > > > > I went ahead and cross-posted to stackoverflow, if anyone wants to try answer there. Seems to get more traffic than mailing lists these day. http://stackoverflow.com/questions/14594786/fancyarrowpatch-to-edge-of-marker-with-known-size Skipper |