I would like to gain more control over the starting point of the annotation arrow in Matplotlib. It seems like the arrow starts at the center of the bbox of the annotation text. However, in many cases I would like to make the xytext coordinates the starting point of the arrow. I visualise my problem below for datapoint (0, 0) and xytext (1, 1) in data coordinates:
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot()
ax.plot(0, 0, linestyle='none', marker='o', markersize=4, c='k')
ax.annotate('annotation', [0, 0], xytext=[1, 1],
ha='left', va='center',
bbox=dict(pad=0, fc='none', ec='k'),
arrowprops=dict(arrowstyle='-'))
ax.plot(1, 1, linestyle='none', marker='o', markersize=4, c='red')
ax.annotate('desired\nanchorpoint', [1, 1], xytext=[0, 1],
ha='center', va='center',
arrowprops=dict(arrowstyle='->', shrinkB=5))
ax.set_xlim([-1, 2])
ax.set_ylim([-1, 2])
It is possible to make one annotation without text and another with text only and no arrow, like proposed in this answer.
I would prefer a solution that uses just one instance of annotate. Is it possible to set xytext as starting point for the arrow of annotate?