添加角度注释箭头和文本
我们将为每种括号箭头样式添加角度注释箭头和文本。首先,我们将获取绘制的补丁在angleA和angleB处的顶部坐标。然后,我们将定义注释箭头的连接方向。最后,我们将向绘图中添加箭头和注释文本。
## Get the top coordinates for the drawn patches at A and B
patch_tops = [get_point_of_rotated_vertical(center, 0.5, angle)
for center, angle in zip(arrow_centers, anglesAB)]
## Define the connection directions for the annotation arrows
connection_dirs = (1, -1) if angle > 0 else (-1, 1)
## Add arrows and annotation text
arrowstyle = "Simple, tail_width=0.5, head_width=4, head_length=8"
for vline, dir, patch_top, angle in zip(vlines, connection_dirs,
patch_tops, anglesAB):
kw = dict(connectionstyle=f"arc3,rad={dir * 0.5}",
arrowstyle=arrowstyle, color="C0")
ax.add_patch(FancyArrowPatch(vline, patch_top, **kw))
ax.text(vline[0] - dir * 0.15, y + 0.7, f'{angle}°', ha="center",
va="center")