Created
October 25, 2018 03:38
-
-
Save sabopy/6877a8cd62ba1e0ab30ed7a56c059910 to your computer and use it in GitHub Desktop.
matplotlib3Dグラフの回転アニメーション
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
from mpl_toolkits.mplot3d import axes3d | |
import matplotlib.pyplot as plt | |
from IPython.display import HTML | |
import matplotlib.animation as animation | |
fig = plt.figure() | |
ax = fig.add_subplot(111, projection='3d') | |
# load some test data for demonstration and plot a wireframe | |
X, Y, Z = axes3d.get_test_data(0.1) | |
#ax.grid(False) | |
#ax.set_axis_off() | |
def init(): | |
ax.plot_wireframe(X, Y, Z, rstride=5, cstride=5) | |
return fig, | |
def animate(i): | |
ax.view_init(elev=30., azim=3.6*i) | |
return fig, | |
# Animate | |
ani = animation.FuncAnimation(fig, animate, init_func=init, | |
frames=100, interval=100, blit=True) | |
HTML(ani.to_html5_video()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment