I am trying to build lines with arrowheads at both ends using the matplotlib annotation. But when I draw them, the arrowhead tips do not start and end at the specified coordinates, as shown in the figure. Tips should begin and end at 0.6 and 0.8, but they do not.

Playable code
import matplotlib.pyplot as plt fig = plt.figure(figsize = (5, 5)) plt = plt.subplot(111) plt.axvline(0.6) plt.axvline(0.8) plt.axhline(0.6) plt.axhline(0.8) plt.annotate('', xy = (0.6, 0.33), xycoords = 'axes fraction', \ xytext = (0.8, 0.33), textcoords = 'axes fraction', fontsize = 7, \ color = '#303030', arrowprops=dict(edgecolor='black', arrowstyle = '<->')) plt.annotate('', xy = (0.33, 0.6), xycoords = 'axes fraction', \ xytext = (0.33, 0.8), textcoords = 'axes fraction', fontsize = 7, \ color = '#303030', arrowprops=dict(edgecolor='black', arrowstyle = '<->')) fig.savefig('arrow_head.pdf')
Why is this happening? And how to get tips for starting or ending in the appropriate coordinates?
source share