How To Draw Dotted Line In The Graph With Text Written On It?
I have plotted a graph using matplotlib. I want to make straight lines with text written on it parallel to y axis in the graph at certain places.Does anyone know how to do that? lo
Solution 1:
You can add these before plt.show()
:
xpos = 2.5#x-value of the vertical line
text = "hello"#text you wanna add to the verical line
plt.vlines(x=xpos, ymin=0, ymax=250, color = 'black', linestyles="dashed")
plt.text(x=xpos, y=125, s=text, ha='center', va='center',rotation='vertical', backgroundcolor='white'))
Which produces:
Post a Comment for "How To Draw Dotted Line In The Graph With Text Written On It?"