Axes.annotate(s, xy, xytext=None, xycoords='data', textcoords=None,
arrowprops=None, annotation_clip=None, **kwargs)
功能:在图形上给数据添加注解。详细信息参考:官方文档。
参数说明:
s: str,注释文本内容。
xy: (float,float), 箭头点所在的坐标位置。
xytext: (float,float),注释内容的坐标位置。
xycoords: str,被注释点的参考坐标系。默认使用表中数据的坐标系。部分可选值如下:
值 | 描述 |
---|---|
‘figure points’ | Points from the lower left of the figure |
‘figure pixels’ | Pixels from the lower left of the figure |
‘figure fraction’ | Fraction of figure from lower left |
‘axes points’ | Points from lower left corner of axes |
‘axes pixels’ | Pixels from lower left corner of axes |
‘axes fraction’ | Fraction of axes from lower left |
‘data’ | Use the coordinate system of the object being annotated (default) |
textcoords: str,注释文本的参考坐标系。默认与xycoords
属性值相同。
color: str,设置注释文本的颜色。默认是黑色。可选值:‘b’, ‘g’, ‘r’, ‘c’, ‘m’, ‘y’, ‘k’, ‘w’。
fontsize: str or int,设置注释文本字体大小。可选值:‘xx–small’ ‘x-small’ ‘small’ ‘medium’ ‘large’ ‘x-large’ ‘xx-large’。
arrowprops:dict,设置指向箭头的参数,字典中key值有
①arrowstyle:设置箭头的样式,可选值:。
②connectionstyle:设置箭头的形状,为直线或者曲线,可选值:‘arc3’,‘arc’,‘angle’,‘angle3’,可以防止箭头被曲线内容遮挡。
③color:设置箭头颜色。
④lw:线条粗细。
bbox:dict,为注释文本添加边框。
参考资料: