-
Notifications
You must be signed in to change notification settings - Fork 0
/
3D_graph_example.py
47 lines (37 loc) · 1.06 KB
/
3D_graph_example.py
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
37
38
39
40
41
42
43
44
45
46
47
import random
from itertools import count
import time
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
from mpl_toolkits import mplot3d
from matplotlib.patches import Circle, PathPatch
from matplotlib.text import TextPath
from matplotlib.transforms import Affine2D
import mpl_toolkits.mplot3d.art3d as art3d
plt.style.use('fivethirtyeight')
x_values = []
y_values = []
z_values = []
q_values = []
w_values = []
index = count()
def animate(i):
x = next(index)
x_values.append(x)
y = random.randint(0, 5)
z = random.randint(3, 8)
q = random.randint(0, 10)
w = random.randint(0, 10)
y_values.append(y)
z_values.append(z)
q_values.append(q)
w_values.append(w)
ax.plot3D(x_values, y_values, z_values, 'blue', linestyle='--')
ax.plot3D(x_values, q_values, z_values, 'red', linestyle='--')
ax.plot3D(x_values, w_values, z_values, 'green', linestyle='--')
time.sleep(.5)
fig = plt.figure()
ax = plt.axes(projection='3d')
ani = FuncAnimation(plt.gcf(), animate, 10)
plt.tight_layout()
plt.show()