In [30]:
%matplotlib inline
In [31]:
from numpy import sin,cos,pi,linspace
from pylab import plot
# Play with these number and ignore the rest
R = 10
r = .4
O = 12
t = linspace(-pi,pi,3000)
x = (R+r)*cos(t) - (r+O)*cos(((R+r)/r)*t)
y = (R+r)*sin(t) - (r+O)*sin(((R+r)/r)*t)
plot(x,y)
Out[31]:
From the command line:
ipython notebook --pylab inline
pylab
bundles some scientific computing libraries together.inline
enables embedded figures in the notebook.Shift-Enter
: run cellCtrl-m b
: insert cell below
In [32]:
print("Hello world")
You can embed your notebook with markdown. Markdown is a lightweight web markup language can be inserted right into the notebook. This is useful for annotating your notebook code samples.
In [43]:
1 + foo
In [34]:
open?
In [35]:
o
In [36]:
# Lissajous curve
from numpy import sin,pi,linspace
from pylab import plot
delta = pi/2
t = linspace(-pi,pi,300)
x = sin(3 * t + delta)
y = sin(5 * t)
plot(x,y)
Out[36]:
The Ipython Notebook uses mathjax to render LaTeX.
$$F(k) = \int_{-\infty}^{\infty} f(x) e^{2\pi i k} dx$$
yields:
$$F(k) = \int_{-\infty}^{\infty} f(x) e^{2\pi i k} dx$$
In [37]:
!ls
In [38]:
from IPython.core.display import Image
Image(url='http://python.org/images/python-logo.gif')
Out[38]:
In [39]:
from sympy import *
init_printing()
x, y = symbols("x y")
Rational(3,2)*pi + exp(I*x) / (x**2 + y)
Out[39]:
In [40]:
loadpy http://matplotlib.org/mpl_examples/pylab_examples/simple_plot.py
In [41]:
from pylab import *
t = arange(0.0, 2.0, 0.01)
s = sin(2*pi*t)
plot(t, s, linewidth=1.0)
xlabel('time (s)')
ylabel('voltage (mV)')
title('About as simple as it gets, folks')
grid(True)
savefig("test.png")
show()
In [42]:
from IPython.display import HTML
HTML('<iframe src=http://nbviewer.ipython.org width=700 height=350></iframe>')
Out[42]: