I would like to add the y values to my plot for each year to make the graph easily readable but not sure how to do it. I have tried using the enumerate function but it does not return the desired output. Any guidance on this would be helpful.
import numpy as np
import pandas as pd
from matplotlib import pyplot
import matplotlib.pyplot as plt
import matplotlib.patches as mpatches
laikipia = pd.DataFrame({
"2020":[5.21, 20.91, 17.05],
"2021":[20.91, 19.91, 19.76],
},
index=["Cropland", "Forestland", "Shrubland"]
)
c = ['#FFDB5C', '#358221', '#EECFA8']
laikipia.plot(kind="bar", color=c)
plt.title("")
plt.xlabel("Laikipia LULC")
plt.ylabel("Area Loss (ha)")
plt.legend(laikipia, bbox_to_anchor=(1, 1))
plt.xticks(rotation=0)
#plt.yticks(round [plotdata], 0)
x = laikipia
y = [70, 60, 50, 40, 30, 20, 10, 0]
max_y_lim = max(y)
min_y_lim = min(y)
plt.ylim(min_y_lim, max_y_lim)
for i, v in enumerate(y):
plt.text(0, i, y[i], str(v), ha="center", va = "bottom")
plt.show()
plt.tight_layout()