Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Josh
- %matplotlib notebook
- import numpy as np
- import matplotlib.pyplot as plt
- def plot_fun(ax,x,t):
- ax.cla()
- ax.plot(x,y,lw=2)
- ax.set_xlim([-1,1]), ax.set_ylim([-1.5,1.5])
- ax.set_xlabel('x'), ax.set_ylabel('f(x,t)')
- fig = plt.figure()
- ax = plt.axes()
- x = np.linspace(-1, 1, 101)
- t = 0
- y = 1/(1+16*((x-t)**2))
- plot_fun(ax,x,t)
- plt.show()
- tfin = 1
- k = 0.01
- while t < tfin:
- t = t + k
- y = 1/(1+16*((x-t)**2))
- plot_fun(ax,x,t)
- plt.draw()
- fig.canvas.draw()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement