# This line configures matplotlib to show figures embedded in the notebook,
# instead of opening a new window for each figure. More about that later.
%pylab inline
import numpy as np
import matplotlib.pyplot as plt
t = np.arange(0,20)
y = np.sin(t)
plt.plot(t,y)
def step(x, y, nx=10):
X = np.linspace(x.min(), x.max(), len(x)*nx)
Y = np.zeros(len(x)*nx)
#Y = np.interp(X, x, y)
for i in xrange(0,len(x)):
for j in xrange(0,nx):
#print i*nx + j
Y[i*nx + j] = y[i]
return X, Y
def lerp(x, y, nx=326, nBlend=50):
X = np.linspace(x.min(), x.max(), len(x)*nx)
Y = np.zeros(len(x)*nx)
for i in xrange(0,len(x)):
for j in xrange(0,nx):
#print i*nx + j
Y[i*nx + j] = y[i]
for i in xrange(0, len(x)-1):
if i == 0:
continue
X_temp = X[i*nx-nBlend:i*nx+nBlend+1]
x_temp = (X[i*nx-nBlend], X[i*nx+nBlend])
y_temp = y[i-1:i+1]
# print x_temp
Y[i*nx-nBlend:i*nx+nBlend+1] = np.interp(X_temp, x_temp, y_temp)
return X, Y
#T,Y = step(t, y)
T, Y = lerp(t, y)
plt.plot(T,Y)
[<matplotlib.lines.Line2D at 0x10f307f10>]