-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAnimation3DExample.py
More file actions
32 lines (24 loc) · 1.02 KB
/
Copy pathAnimation3DExample.py
File metadata and controls
32 lines (24 loc) · 1.02 KB
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
# From https://stackoverflow.com/questions/5179589/continuous-3d-plotting-i-e-figure-update-using-python-matplotlib
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import matplotlib
class plot3dClass(object):
def __init__(self, systemSideLength, lowerCutoffLength):
self.systemSideLength = systemSideLength
self.lowerCutoffLength = lowerCutoffLength
self.fig = plt.figure()
self.ax = self.fig.add_subplot(111, projection='3d')
rng = np.arange(0, self.systemSideLength, self.lowerCutoffLength)
self.X, self.Y = np.meshgrid(rng, rng)
heightR = np.zeros(self.X.shape)
self.surf = self.ax.scatter(self.X, self.Y, heightR, c="#ff00ff")
def drawNow(self, heightR):
self.surf.remove()
self.surf = self.ax.scatter(self.X, self.Y, heightR, c="#ff00ff")
plt.draw()
self.fig.canvas.flush_events()
matplotlib.interactive(True)
p = plot3dClass(5, 1)
while True:
p.drawNow(np.random.random(p.X.shape))