import packages

In [1]:
%matplotlib notebook
from pylab import *
from numpy import *

line plot

In [2]:
l = 15.5
x = arange(-l,l,.2)
y = sin(x)/x
fig = figure()
plot(x,y)
axis([-l,l,-.3,1.1])
show()
fig.savefig("line.eps")

image plot

In [3]:
from matplotlib import cm
l = 15.5
fig = figure()
x = arange(-l, l, 0.2)
y = arange(-l, l, 0.2)
(x,y) = meshgrid(x,y)
r = sqrt(x**2 + y**2)
z = sin(r)/r
imshow(z,extent=[-l,l,-l,l],cmap=cm.gray)
show()
fig.savefig("image.eps")

surface plot

In [4]:
from mpl_toolkits.mplot3d import Axes3D
l = 15.5
fig = figure()
ax = Axes3D(fig)
x = arange(-l, l, 0.8)
y = arange(-l, l, 0.8)
(x,y) = meshgrid(x,y)
r = sqrt(x**2 + y**2)
z = sin(r)/r
ax.plot_surface(x,y,z,rstride=1,cstride=1,cmap=cm.gray)
show()
fig.savefig("surface.eps")