matplotlib 添加数据标签

想在图上添加数据标签
    for a,b in zip(x,y3):
        plt.text(x, y3, str(y3), ha='center', va='bottom', fontsize=10.5)#出来的是空白的
    for a, b in zip(x, y3):
        plt.text(x, y3+0.03, '%.0f'%y3, ha='center', va='bottom', fontsize=10.5)#直接报错

报错信息如下

img


附画图代码

x = np.arange(mouth) + 1
y1=df ["2022年"]
y2=df ["2021年"]
y3=df .同比增长率
plt.bar(x, y1, bar_width, label="2022年")
plt.bar(x+bar_width, y2, bar_width, label="2021年")#str(bar_width)

plt.ylim(min(y1.min(), y2.min())*0.8, max(y1.max(), y2.max()) * 1.2) # 设置坐标轴的取值范围,避免柱子过高而与图例重叠
plt.legend(loc='upper left')   # 设置图例
plt.xticks(x) # 设置横坐标的标签
    # 在次坐标轴上绘制折线图
plt.twinx()
plt.plot(x, y3, ls='-', lw=3, color='red', marker='o', label='同比增长率')    # ls:线的类型,lw:宽度,o:在顶点处实心圈
plt.ylim(y3.min()-0.1, y3.max()+0.1)    # 设置次坐标轴的取值范围,避免折线图波动过大