In [ ]:
from IPython.core.display import HTML

with open('../../common/creativecommons.html', 'r') as f:
    html = f.read()
    
with open('../../common/custom.css', 'r') as f:
    styles = f.read()
    
HTML(styles)

text = 'Check this post at'
uri = 'http://nbviewer.ipython.org/urls/raw.github.com/ocefpaf/python4oceanographers/master/content/downloads/notebooks'
name = get_notebook_name()
link = """<p>%s <a href="%s/%s"><em>nbviewer</em>.</a></p>""" % (text, uri, name)
html += str(link)

In [ ]:
import numpy as np
import matplotlib.pyplot as plt

In [ ]:
hoL = np.arange(0, 1, 0.001)
kh = 2 * np.pi * hoL
tanhkh = np.tanh(kh)

threshold = 1e-3
one = (1 - tanhkh) <= threshold
equal = (kh - tanhkh) <= threshold

fig, ax = plt.subplots(figsize=(8, 4))
ax.plot(hoL, tanhkh, color='#493D26', linewidth='2', label=r"$\tanh(kh)$")
ax.plot(hoL[equal], tanhkh[equal], color='#F88017', linewidth='3', label=r"$\tanh(kh) \sim kh$")
ax.plot(hoL[one], tanhkh[one], color='#168EF7', linewidth='3', label=r"$\tanh(kh) \sim 1$")
ax.set_xlabel(r'$\frac{h}{L}$')
ax.set_ylabel(r'$\tanh(kh)$')
ax.axis([0, 1, 0, 1.05])
ax.legend(loc='lower right')

plt.show()

In [ ]:
HTML(html)