In a plot, I would like to draw an axhline
in a particular plot which is annotated by its value, a bit like the contour plot example here. E.g. looking something like: --------- 0.13 -----------
.
Is this possible in matplotlib
?
You can create a normal text
object at the center point of the line and then set the background color to the color of the axes so that the horizontal line is not visible behind the text.
plt.axhline(linewidth=4, y=0.5, color='red')
plt.text(0.5, 0.5, 'text', fontsize=30, va='center', ha='center', backgroundcolor='w')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With