0
我在python 2.7中使用matplotlib。我正在試圖在軸外的圖形區域中創建一個箭頭。在圖形區域繪製帶銳利邊緣的箭頭
from matplotlib.pyplot import *
fig = figure()
ax1 = fig.add_axes([.1,.1,.6,.8])
ax1.annotate('',xy=(.8,.92),xycoords='figure fraction',xytext=(.8,.1)
arrowprops=dict(arrowstyle='->',fc='k',lw=10))
ax2 = fig.add_axes([.85,.1,.1,.8])
ax2.spines['top'].set_visible(False)
ax2.spines['bottom'].set_visible(False)
ax2.spines['left'].set_visible(False)
ax2.spines['right'].set_visible(False)
ax2.tick_params(axis='both',which='both',
top='off',right='off',left='off',bottom='off',
labeltop='off',labelright='off',labelleft='off',labelbottom='off')
ax2.patch.set_facecolor('None')
ax2.set_xlim(0,1)
ax2.set_ylim(0,1)
ax2.arrow(.5,0,0,1,fc='k',ec='k',head_width=.25,
head_length=.05,width=.15,length_includes_head=True)
show()
使用
ax1.annotate(...)
給了我一個 '模糊' 看箭頭。我能弄清楚如何得到一個更好的看箭頭的唯一方法是通過創建另一個軸只是爲了添加箭頭,使用
ax2.arrow(...)
(網站不會讓我張貼圖片,但複製和粘貼代碼你會看到我在說什麼) 還有一個更好的方式來做到這一點,雖然...