I have written a code to examine the alias effect for a sine-wave. The code produces a series of plots, which show the results of sampling the sine-wave at a given sampling frequency. The frequency of the sinewave is increased in increments of 50 hz using while-loop logic.
import numpy as np
from math import pi
import matplotlib.pyplot as plt
f_0 = 50
f_s = 150
t_a = np.arange(0, 0.1, 10e-06)
t_d = np.arange(1/f_s, 0.1, 1/f_s)
def a_sinewave(t_a, f_0):
return np.sin(2 * pi * f_0 * t_a)
def d_sinewave(t_d, f_0):
return np.sin(2 * pi * f_0 * t_d)
while f_0 <= 300:
y = a_sinewave(t_a, f_0)
z = d_sinewave(t_d, f_0)
plt.plot(t_a, y)
plt.plot(t_d, z, 'ro')
plt.show()
f_0 += 50
Running this code displays a series of plots for each value of f_0, one after another. I would like to display these plots as a "slide-show", as in one plot is shown every t seconds. How can I do this?