Python 如何在matplotlib中更改曲线B的箭头宽度和长度?

Python 如何在matplotlib中更改曲线B的箭头宽度和长度?,python,matplotlib,Python,Matplotlib,我正在尝试使用下面给出的代码创建带有箭头的注释: import matplotlib.pyplot as plt figure = plt.figure(figsize=(5.15, 5.15)) figure.clf() plot = plt.subplot(111) plot.set_xlabel(r'\textit{X}', labelpad=6) plot.set_ylabel(r'\textit{Y}', labelpad=6) plt.annotate(r'\textit{P}',

我正在尝试使用下面给出的代码创建带有箭头的注释:

import matplotlib.pyplot as plt
figure = plt.figure(figsize=(5.15, 5.15))
figure.clf()
plot = plt.subplot(111)
plot.set_xlabel(r'\textit{X}', labelpad=6)
plot.set_ylabel(r'\textit{Y}', labelpad=6)
plt.annotate(r'\textit{P}', xy = (0.5, 0.5),  \
    xycoords = 'data', xytext = (0.4, 0.4), \
    textcoords = 'data', fontsize = 7, arrowprops=dict(arrowstyle = "->"))
plt.show()
我尝试按如下方式更改头部宽度和头部长度:

arrowprops=dict(arrowstyle = "->", head_width = 0.2, head_length = 0.1)
但它给了我以下错误:

AttributeError: 'FancyArrowPatch' object has no attribute 'set_head_width'
如何在matplotlib中更改头长、头宽和体宽?

使用头宽和分形指定箭头的宽度和长度
frac是以总箭头长度的分数表示的头长

plt.annotate(r'\textit{P}', xy = (0.5, 0.5),  \
    xycoords = 'data', xytext = (0.4, 0.4), \
    textcoords = 'data', fontsize = 7, arrowprops=dict(headwidth = 15, frac = 0.5))