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

Aliasing The code below plots sine waves of a given frequency, along with their representation on a grid with $m$ points. Try changing $p$ and notice how for $m<2p$ the function looks identical to that for $2(m+1)-p$ due to aliasing.

In [2]:
from matplotlib import animation
import matplotlib.pyplot as plt
from clawpack.visclaw.JSAnimation import IPython_display

fig = plt.figure()
ax = plt.axes(xlim=(0, 1), ylim=(-1.2, 1.2))

x=np.linspace(0,1,m+2); # grid
xf=np.linspace(0,1,1000) # fine grid

line1, = ax.plot([],[], '-r', lw=2)
line2, = ax.plot([],[],'o-',lw=2)

def fplot(p):
    line1.set_data(xf, np.sin(p*np.pi*xf))
    return line2,

anim = animation.FuncAnimation(fig, fplot, frames=range(0,44))
IPython_display.display_animation(anim, show_buttons=True)

Once Loop Reflect