To have full control of the distance, you must combine jrjc and Ffisegydd answers.
The pad
property of the Bbox defines the distance between the text and its containing box. The shrink
property of the arrow is the distance between the arrow extremity and the box, not the text itself.
Also, to use shrink
with FancyArrowPatch
you must defined it separately: shrinkA
for the origin (extremity of the arrow close to the text) and shrinkB
for the destination.
From a demo in Matplotlib's website:
ax.annotate("",
xy=(x1, y1), xycoords='data',
xytext=(x2, y2), textcoords='data',
arrowprops=dict(arrowstyle="->", color="0.5",
shrinkA=5, shrinkB=5,
patchA=None, patchB=None,
connectionstyle=connectionstyle,
),
)
So the full answer is both:
plt.annotate('Example text',
xy=(-1,-1), xytext=(0,0),
arrowprops=dict(arrowstyle='->', shrinkA=0.15),
bbox=dict(pad=0),
)
Examples:
