Matplotlib Annotation
Contents
Matplotlib 中有两种标注,一种是无指向性标注 text,另一种是指向性注释 annotate。
无指向性标注 text:
plt.text(-0.5, 5, "two functions", family="Times New Roman", fontsize=18, fontweight="bold", color='red')
# 在 x 为-0.5,y 为 5 的区域开始文本标注
指向性注释 annotate。 annotate()函数用于注释,xy 参数代表箭头指向的点,xytext 代表文本标注开始的点:
加 circle
1 | import matplotlib.pyplot as plt |
plt.annotate
:
xy(float, float)
: The point (x, y) to annotate. The coordinate system is determined by xycoords.xytext(float, float)
, default: xy: The position (x, y) to place the text at. The coordinate system is determined by textcoords.
参考资料
How do I put a circle with annotation in matplotlib matplotlib.pyplot.annotate — Matplotlib 3.7.2 documentation
图例 Legend,标注(Text,Annotate)【Matplotlib 入门教程 4】 – TuringPlanet