2011-10-30 97 views
10

如果我想使用箭頭/箭頭功能之一繪製箭頭而不是軸線,我該如何顯示線條/箭頭?示例如下:如何使用pyplot.arrow或patches.Arrow在matplotlib中?

import matplotlib.pyplot as plt 
import matplotlib.patches as pts 

plt.ion() 
ax = plt.axes() 
ax.set(xlim=[0,1],ylim=[0,1],autoscale_on=False,clip_on=False) 
ax.set(frame_on=False,xticks=[],yticks=[]) 
pts.Arrow(0,0,1,0,width=0.05) 
plt.arrow(0,0,0,1,shape='right',lw=3,fill=True) 
ax.text(1,0,'functionalization', 
     verticalalignment='top', 
     horizontalalignment='center') 
ax.text(0,1,'void space/structure') 
plt.draw() 

pts.Arrow沒有畫任何東西,plt.arrow畫了一條線但沒有箭頭。

回答

14
plt.arrow(0,0,0,1, shape='full', lw=3, length_includes_head=True, head_width=.01)