title: Add a label to y-axis to show the value of y for a horizontal line in matplotlib
body: <p>How can I add a string label to the horizontal red line showed in the following plot? I want to add something like "k=305" to the y-axis label next to the line. The blue dots are just some other data and the values do not matter. For recreation of this problem, you can plot any kind of data. My question is about the red line. </p>
  
  <pre><code>plt.plot((0,502),(305,305),'r-')
  plt.title("ALS+REG")
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/5Iepv.png" rel="noreferrer"><img src="https://i.stack.imgur.com/5Iepv.png" alt="plot"></a></p>