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 33 34
| def lorenz_3d_plot_ani(data): fig = plt.figure() ax = Axes3D(fig)
ax.xaxis.set_pane_color((1, 1, 1, 1)) ax.yaxis.set_pane_color((1, 1, 1, 1)) ax.zaxis.set_pane_color((1, 1, 1, 1))
ax.set_title('Lorenz_3d_animation')
ax.set_xlim3d([-0.5, 0.5]), ax.set_xlabel('X') ax.set_ylim3d([-0.5, 0.5]), ax.set_ylabel('Y') ax.set_zlim3d([0.0, 1.0]), ax.set_zlabel('Z')
def update_line(num, data, line): line.set_data(data[0:2, :num]) line.set_3d_properties(data[2, :num]) return line
line, = ax.plot(data[0][0:1], data[1][0:1], data[2][0:1], color='r', alpha=0.7, linewidth=0.75) ani = animation.FuncAnimation(fig, update_line, 1000, fargs=(data, line), interval=1)
ani.save('03_lorenz_3d_ani.gif') plt.show()
lorenz_3d_plot_ani(data)
|