import numpy as np import matplotlib.pyplot as plt from IPython import display x = np.linspace(0, 6 * np.pi, 100) cos_values = [] sin_values = [] for i in range(len(x)): # add the sin and cos of x at index i to the lists cos_values.append(np.cos(x[i])) sin_values.append(np.sin(x[i])) # graph up until index i plt.plot(x[:i], cos_values[:i], label='Cos') plt.plot(x[:i], sin_values[:i], label='Sin') plt.xlabel('input') plt.ylabel('output') # lines that help with animation display.clear_output(wait=True) # replace figure plt.pause(.01) # wait between figures