I want to put a text slightly above a horizontal line, the value of y where is variable, not a constant in a matplotlib figure. My current code is following:
fig, host = plt.subplots(figsize=(18,6))
plt.axhline(y = *a variable between 0-100*, color='r')
plt.text(*x-cord*, *y-cord* , '*Desired Text*', verticalalignment='bottom', horizontalalignment='right', transform=host.transAxes, color='red', fontsize=14)
However, the position of the text depends on x-coord, y-coord. As my horizontal line is a variable, every time I have to manually adjust the text position, which is not optimal for me to automate the figure creation.