5
我想繪製兩端帶箭頭的線條使用matplotlib的註釋。但是,當我繪製它們時,箭頭標記不會在指定的座標處開始或結束,如圖所示。提示應該開始和結束在0.6和0.8,但他們不。如何獲得箭頭頭提示開始/結束在Python中的指定座標?
重現代碼
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')
爲什麼會出現這種情況?以及如何讓提示開始或結束在相應的座標?