增加matplotlib注释双面箭头中的厚度

增加matplotlib注释双面箭头中的厚度,matplotlib,Matplotlib,width参数适用于单面箭头,但在使用双面箭头时出现错误 import numpy as np import matplotlib.pyplot as plt x = np.linspace(0, 10, 1000) plt.plot(x, np.sin(x)); plt.annotate('', xy=(3.2, 0), xycoords='data', xytext=(5.9, 0), textcoords='data', arrowpr

width
参数适用于单面箭头,但在使用双面箭头时出现错误

import numpy as np
import matplotlib.pyplot as plt

x = np.linspace(0, 10, 1000)
plt.plot(x, np.sin(x));
plt.annotate('', xy=(3.2, 0), xycoords='data',
             xytext=(5.9, 0), textcoords='data',
             arrowprops=dict(facecolor='black', width=3))
这样做效果很好,并导致此绘图:

该代码也适用于未指定宽度的双面箭头:

plt.annotate('', xy=(3.2, 0), xycoords='data',
             xytext=(5.9, 0), textcoords='data',
             arrowprops=dict(facecolor='black', arrowstyle='<->'))
plt.annotation(“”,xy=(3.2,0),xycoords='data',
xytext=(5.9,0),textcoords='data',
arrowprops=dict(facecolor='black',arrowstyle=''')

但对于具有宽度的双箭头:

plt.annotate('', xy=(3.2, 0), xycoords='data',
             xytext=(5.9, 0), textcoords='data',
             arrowprops=dict(facecolor='black', width=3, arrowstyle='<->'))
plt.annotation(“”,xy=(3.2,0),xycoords='data',
xytext=(5.9,0),textcoords='data',
arrowprops=dict(facecolor='black',width=3,arrowstyle=''')
导致matplotlib错误:“AttributeError:未知属性宽度”

请尝试以下操作:

arrowprops=dict(facecolor='black', lw=3, arrowstyle='<->')
arrowprops=dict(facecolor='black',lw=3,arrowstyle=''')

我想你想要的是“线宽”这一技巧。我不是疯了,对吧?看来行话应该统一起来。