Matplotlib花式箭头/补丁边缘宽度

时间:2019-03-21 14:45:41

标签: python matplotlib

以下代码将生成带有matplotlib的花式箭头:

import matplotlib.pyplot as plt

xy = [0.2,0.2]
xytext =[0.5,0.5]

plt.figure()
ax = plt.gca()
ax.annotate("", xy=xy, xytext=xytext,arrowprops=dict(arrowstyle="<|-", edgecolor = 'k', facecolor = 'r', shrinkA = 0, shrinkB = 0))

箭头为红色,黑色边缘。如何控制黑色边缘的宽度?

enter image description here

1 个答案:

答案 0 :(得分:0)

您可以使用linewidth参数。下面是一个示例

import matplotlib.pyplot as plt

xy = [0.2,0.2]
xytext =[0.5,0.5]

plt.figure()
ax = plt.gca()
ax.annotate("Text", xy=xy, xytext=xytext, arrowprops=dict(arrowstyle="<|-, 
            head_width=2, head_length=2", edgecolor = 'k', facecolor = 'r',
            linewidth=4))

enter image description here