Skip to content

Instantly share code, notes, and snippets.

@daguiam
Last active May 10, 2018 14:31
Show Gist options
  • Save daguiam/aa4824e3b4718613abfbeccecdae9225 to your computer and use it in GitHub Desktop.
Save daguiam/aa4824e3b4718613abfbeccecdae9225 to your computer and use it in GitHub Desktop.
import numpy as np
from mpl_toolkits.mplot3d import axes3d
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
import matplotlib.animation as animation
import matplotlib.colors as colors
# # Set up formatting for the movie files
Writer = animation.writers['ffmpeg']
writer = Writer(fps=15, metadata=dict(artist='Me'), bitrate=1800)
fig = plt.figure()
fig.add_subplot(111, projection='3d')
# ax = plt.gca()
# ps = plt.gca().plot_surface(X, Y, Z,cmap='viridis', shade=False, rcount=200, ccount=500,
# edgecolor='k', linewidth=0.01, zorder=100, rasterized=True)
x = np.arange(-9, 10)
y = np.arange(-9, 10).reshape(-1, 1)
base = np.hypot(x, y)
ims = []
for add in np.arange(15):
ims.append((plt.gca().plot_surface(x, y, base + add, norm=plt.Normalize(0, 30)),))
im_ani = animation.ArtistAnimation(fig, ims, interval=50, repeat_delay=3000,
blit=True, repeat=True)
im_ani.save('im.mp4', writer=writer)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment