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).
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()
Here is the result:
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:
I tried the solution provided here, which looks promising, but could not make it work. I modified my code as follows:
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")
but could not figure out the correct parameters for the label_line function in relation to my code.
Could someone give me a few hints?
Thanks in advance!
Best regards,