how to use pyplot.arrow or patches.Arrow in matplo

2020-07-06 04:12发布

问题:

If I wanted to draw arrows instead of axis lines using one of the arrow/Arrow functions, how do I get the line/arrowhead to show up? Example below:

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 draws nothing, and plt.arrow draws a line but no arrowhead.

回答1:

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


标签: matplotlib