matplotlib 简单和两个头箭头
·
回答问题
我想做一个简单的箭头和一个两头箭头。我使用以下方法制作了一个简单的箭头,但我怀疑这是最简单的方法:
import matplotlib.pyplot as plt
arr_width = .009 # I don't know what unit it is here.
fig = plt.figure()
ax1 = fig.add_subplot(111)
ax1.plot(range(10))
ax1.arrow(1, 1, 0, .5, width = arr_width, head_width = 3 * arr_width,
head_length = 9 * arr_width)
plt.show()
我找不到如何用这种方法制作两个头箭头。
Answers
您可以使用带有空白文本注释的annotate方法创建一个双头箭头,并将arrowpropsdict 设置为包含arrowstyle='<->',如下所示:
import matplotlib.pyplot as plt
plt.annotate(s='', xy=(1,1), xytext=(0,0), arrowprops=dict(arrowstyle='<->'))
plt.show()

更多推荐

所有评论(0)