FancyArrowPatch to edge of marker with known size?

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(dx2 + dy2)

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

···

On Tue, Jan 29, 2013 at 5:11 PM, Skipper Seabold <jsseabold@…287…> 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(dx2 + dy2)

arrows = FancyArrowPatch(posA=(x1, y1), posB=(x2, y2),

color = ‘k’,

arrowstyle="-|>",

mutation_scale=700**.5,

connectionstyle=“arc3”)

ax.add_patch(arrows)

Can you elaborate why you cannot just use shrinkA and shrinkB?

arrows = FancyArrowPatch(posA=(x1, y1), posB=(x2, y2),
                         color = 'k',
                         arrowstyle="-|>",
                         mutation_scale=700**.5,
                         shrinkA=(700**.5)*.5, shrinkB=(700**.5)*.5,
                         connectionstyle="arc3")

What the problem of doing above?

Note that the unit of shrinkA and shrinkB is points, and they are
independent of mutation_scale, which only affects the size of the arrow.

Regards,

-JJ

···

On Wed, Jan 30, 2013 at 7:11 AM, Skipper Seabold <jsseabold@...287...>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?