title: Anottating along a Matplotlib curve
body: <p>I wrote a simple script for plotting the immigration/extinction curves for large/small and near/far islands according to the classical MacArthur-Wilson model ("The Theory of Island Biogeography", Princeton University Press, 1967).</p>
  
  <pre><code>from __future__ import division
  from math import log
  import numpy as np
  import matplotlib.pyplot as plt
  
  I0 = log(1)
  b = 0.1
  d = 0.01
  
  s = np.linspace(0, 50, 10)
  z1 = np.exp(I0 - b * s)
  z2 = np.exp(d * s) - 1
  
  I0 = log(1/2)
  d = 0.014
  z3 = np.exp(I0 - b * s)
  z4 = np.exp(d * s) - 1
  
  plt.xlabel("No. of Species (R)")
  plt.ylabel("Rate (I or E)")
  plt.ylim(0.0, 1.0)
  plt.plot(s, z1)
  plt.plot(s, z2)
  plt.plot(s, z3, linestyle="--")
  plt.plot(s, z4, linestyle="--")
  plt.show()
  </code></pre>
  
  <p>Here is the result:</p>
  
  <p><a href="https://i.stack.imgur.com/313XR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/313XR.png" alt="enter image description here"></a></p>
  
  <p>It works fine, but I want to annotate the curves, to identify each one according to its size and distance from the species pool. The figure below show what I would like to obtain:</p>
  
  <p><a href="https://i.stack.imgur.com/JlcuS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JlcuS.png" alt="enter image description here"></a></p>
  
  <p>I tried the solution provided <a href="https://stackoverflow.com/questions/18780198/how-to-rotate-matplotlib-annotation-to-match-a-line">here</a>, which looks promising, but could not make it work. I modified my code as follows:</p>
  
  <pre><code>fig, axes = plt.subplots()
  plt.xlabel("No. of Species (R)")
  plt.ylabel("Rate (I or E)")
  plt.ylim(0.0, 1.0)
  line1, = axes.plot(s, z1)
  line2, = axes.plot(s, z2)
  line3, = axes.plot(s, z3, linestyle="--")
  line4, = axes.plot(s, z4, linestyle="--")
  label_line(line3, "Some Label", s, z3, color="black")
  </code></pre>
  
  <p>but could not figure out the correct parameters for the label_line function in relation to my code.</p>
  
  <p>Could someone give me a few hints?</p>
  
  <p>Thanks in advance!</p>
  
  <p>Best regards,</p>