Pandas怎样结合matplotlib画一个带标签数字的柱状图

import matplotlib.pyplot as plt

fig, ax = plt.subplots(figsize = (12,5))
plt.bar(df_rn["bkt"], df_rn["rating"],width=0.4)
for index,data in zip(df_rn["bkt"], df_rn["rating"]):
    data = round(data, 4)
    plt.text(x=index , y =data+0.002 , s=f"{data}")
plt.tight_layout()
plt.show()

figsize参数的解释:

figsize : (float, float), optional, default: None

width, height in inches. If not provided, defaults to rcParams[“figure.figsize”] = [6.4, 4.8].

你可能感兴趣的:(Pandas系列)