41 lines
998 B
Python
41 lines
998 B
Python
import time
|
|
import random
|
|
from random import randrange
|
|
import matplotlib.pyplot as plt
|
|
import numpy as np
|
|
|
|
fig = plt.figure()
|
|
ax = fig.add_subplot(projection='3d')
|
|
|
|
# Make the X, Y meshgrid.
|
|
xs = np.linspace(-1, 1, 50)
|
|
ys = np.linspace(-1, 1, 50)
|
|
X, Y = np.meshgrid(xs, ys)
|
|
|
|
# Set the z axis limits, so they aren't recalculated each frame.
|
|
ax.set_zlim(-1, 1)
|
|
|
|
# Begin plotting.
|
|
wframe = None
|
|
tstart = time.time()
|
|
import random
|
|
|
|
rand_list=[]
|
|
n=50
|
|
for i in range(n):
|
|
rand_list.append(random.randint(3,9))
|
|
print(rand_list)
|
|
rand_list.sort()
|
|
for phi in range(0,50):
|
|
#for phi in np.linspace(0, 180. / np.pi, 100):
|
|
# If a line collection is already remove it before drawing.
|
|
if wframe:
|
|
wframe.remove()
|
|
# Generate data.
|
|
Z = np.cos(2 * np.pi * X + phi) * (1 - np.hypot(X, Y))
|
|
# Plot the new wireframe and pause briefly before continuing.
|
|
wframe = ax.plot_wireframe(X, Y, Z, rstride=2, cstride=2)
|
|
plt.pause(.08)
|
|
|
|
print('Average FPS: %f' % (100 / (time.time() - tstart)))
|