-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTHIS_IS_FOR_YOU.py
More file actions
36 lines (27 loc) · 814 Bytes
/
THIS_IS_FOR_YOU.py
File metadata and controls
36 lines (27 loc) · 814 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
def f(x, a):
return (x**(2/3) + np.e/3 * ((np.pi - x**2)**(1/2)) * np.sin(a * np.pi * x))*4
def init():
line1.set_data([], [])
line2.set_data([], [])
return line1,line2
def update(frame):
a = frame * 1
y = f(x, a)
line1.set_data(-x, y)
line2.set_data(x, y)
return line1,line2
x = np.linspace(0, np.pi, 1000)
fig, ax = plt.subplots()
ax.set_xlim(-3, 3)
ax.set_ylim(-10, 10)
line1, = ax.plot([], [], color='r')
line2, = ax.plot([], [], color='r')
plt.xticks([], [])
plt.yticks([], [])
plt.title('This is for you!❤')
ani = FuncAnimation(fig, update, frames=range(40), init_func=init, blit=True)
ani.save('heart.mp4', fps=10, extra_args=['-vcodec', 'libx264'])
plt.show()