Last active
October 24, 2016 03:24
-
-
Save t-makaro/b50422634a6ca5c66f58cd4bf2a45063 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
from mpl_toolkits.mplot3d import axes3d | |
from matplotlib import cm | |
import matplotlib.animation as animation | |
import numpy as np | |
#plt.rcParams['animation.ffmpeg_path'] = 'some directory/ffmpeg-20150317-git-d24af70-win64-static/bin/ffmpeg' | |
plot_args = {'rstride':1, 'cstride':1, 'cmap':cm.coolwarm, 'linewidth':0, 'antialiased':False} | |
titleString = r'$z = \frac{1}{(12 \tan^{-1}(\frac{y}{|x|})+ \frac{3\pi}{2}\sin(2\pi t))^2 + 1}$' | |
fig = plt.figure() | |
ax = fig.gca(projection='3d') | |
X = np.arange(-5, 5.25, 0.251) | |
Y = np.arange(-2, 2.1, 0.101) | |
X, Y = np.meshgrid(X, Y) | |
def wings(x, y, t): | |
phi = 12*(np.arctan(y/abs(x)) + np.pi/8*np.sin(2*np.pi*t)) | |
return 1/(phi*phi + 1) | |
def data_gen(i): | |
ax.clear() | |
plt.title(titleString) | |
plot = ax.plot_surface(X,Y, wings(X,Y,i/30.), **plot_args) | |
return plot, | |
Z = wings(X,Y, 0) | |
plot = ax.plot_surface(X,Y, Z, **plot_args) | |
anim = animation.FuncAnimation(fig, data_gen, interval=30, blit=False) | |
ax.set_zlim(0, 1.01) | |
plt.title(titleString) | |
#FFwriter = animation.FFMpegWriter() | |
#anim.save('Tie1.mp4',fps=30, writer = FFwriter) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I just sort of smashed this code together with the help of examples.