你只需要为添加另一个for循环
y1
以对数据进行注释。我还将
x
到
x_
作为迭代器的名称,否则它将覆盖原始变量。
for x_, y in zip(x, y1):
label = y
plt.annotate(label, (x_, y),
xycoords="data",
textcoords="offset points",
xytext=(0, 10), ha="center", color ='blue')
for x_, y in zip(x, y2):
label = y
plt.annotate(label, (x_, y),
xycoords="data",
textcoords="offset points",
xytext=(0, -10), ha="center", color= 'orange')
输出: