Testing iPython setup

  |   Source

tl;dr Nikola does iPython notebooks almost out of the box! See it in action, and download the .ipynb source of that very blog post.

One of the features that attracted me to using Nikola is the ability to embed iPython Notebooks. I am using notebooks to code, to keep notes about stuff, to script tedious aspects of my work, and putting it all together seems like a great time saver! I am now using jupyter-notebook to do it all in one go, with the added bonuses that it's on a blog and it's version controlled!

In [10]:
%matplotlib inline
import matplotlib.pyplot as plt # side-stepping mpl backend
import matplotlib.gridspec as gridspec # subplots

fig1 = plt.figure()
# Make a legend for specific lines.
import matplotlib.pyplot as plt
import numpy as np

t1 = np.arange(0.0, 2.0, 0.1)
t2 = np.arange(0.0, 2.0, 0.01)

# note that plot returns a list of lines.  The "l1, = plot" usage
# extracts the first element of the list into l1 using tuple
# unpacking.  So l1 is a Line2D instance, not a sequence of lines
l1, = plt.plot(t2, np.exp(-t2))
l2, l3 = plt.plot(t2, np.sin(2 * np.pi * t2), '--go', t1, np.log(1 + t1), '.')
l4, = plt.plot(t2, np.exp(-t2) * np.sin(2 * np.pi * t2), 'rs-.')

plt.title('Damped oscillation')

In [11]:
import pylab as p

xs = p.linspace(0, 40, 200)
p.plot(xs, f(xs, 0.1), label ='f(x, 0.1)')
p.plot(xs, f(xs, 0.2), '--', label ='f(x, 0.2)')
<matplotlib.legend.Legend at 0x1058e9890>
In [ ]:
Comments powered by Disqus