Reputation: 73
So I have a plot but I do not get how to add data labels to my figures. I get the desired plots but I would like to see the y-value for each point. Here is the code:
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")
Upvotes: 0
Views: 55
Reputation: 85
You can try the following, just add it under #add labels
(Also see: Add x and y labels to a pandas plot)
lines.set_xlabel("x label")
lines.set_ylabel("y label")
Upvotes: 1