-
-
Save abevieiramota/c6064595771cebf7831b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as pl | |
import matplotlib.animation as animation | |
import numpy as np | |
x_min, x_max = 0, 500 | |
y_min, y_max = 0, 500**3 | |
def f1(x): | |
return x**3 | |
def f2(x): | |
return 400*x**2 | |
x = np.arange(0, 500, 1) | |
fig = pl.figure() | |
ax = pl.axes(xlim=(x_min, x_max), ylim=(y_min, y_max)) | |
line1, = ax.plot([], [], lw=2, c='y', label="$x^3$") | |
line2, = ax.plot([], [], lw=2, c='b', label="$400x^2$") | |
lines = [line1, line2] | |
pl.legend(loc='upper left') | |
def init(): | |
line1.set_data([], []) | |
line2.set_data([], []) | |
return lines | |
def anima(i): | |
x_frame = x[:i] | |
y1_frame = f1(x_frame) | |
y2_frame = f2(x_frame) | |
line1.set_data(x_frame, y1_frame) | |
line2.set_data(x_frame, y2_frame) | |
return lines, | |
anim = animation.FuncAnimation(fig, anima, init_func=init, frames=500, interval=25, blit=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment