I have a dataframe with multiple columns (columns represent months) and each row is a group, e.g.
OCT20 NOV20 DEC20 JAN21
A 20 24 19 18
B 45 29 33 46
C 19 11 13 11
(This is just dummy data to get a reproducible solution).
I am plotting a line plot of this dataframe, with the columns as x-ticks and each row in the index as a line in the plot, and the values for each month per row are the y values.
Below is the code I use for plotting, which works fine. However, I want to annotate each datapoint with its value from the dataframe, but with the code below I get all the datapoints in one place.
%matplotlib inline
labels = ['OCT20', 'NOV20', 'DEC20', 'JAN21', 'FEB21', 'MAR21']
ax = df.T.plot(grid = True, figsize=(20,15), marker='o')
for col in df.columns:
for id, val in enumerate(df[col]):
ax.text(id, val, str(val))
x = [0,1,2,3,4,5]
plt.xticks(x, labels, rotation=45)
plt.show()
But I want each datapoint to correspond to the correct marker in the plot.
Anyone know how to solve this?

