如何为熊猫matplotlib图形添加(x,y)标签?

时间:2020-01-14 09:20:20

标签: python pandas matplotlib

所以我有一个图,但是我不知道如何在数据中添加数据标签。我得到了所需的图,但我想查看每个点的y值。这是代码:

list_of_centers=os.listdir("./")
for i in range(len(list_of_centers)):

    xls = pd.ExcelFile("./"+list_of_centers[i])
    for j in range(len(xls.sheet_names)):

        df=pd.read_excel("./"+list_of_centers[i])
        df=df.drop(columns=['Y', 'C','O','Y_C','Y_O'])
        df=df.set_index('Date')
        lines = df.plot.line(title=list_of_centers[i][:-5]+"_"+xls.sheet_names[j])


    #add labels


        plt.savefig("./"+list_of_centers[i] 
        [:-5]+"_"+xls.sheet_names[j]+".png")

1 个答案:

答案 0 :(得分:1)

您可以尝试以下操作,只需将其添加到Enum下(另请参见:Add x and y labels to a pandas plot

#add labels