Created
September 9, 2018 22:16
-
-
Save SkalskiP/cbfe9f00b2718471468b2b8be432e7d7 to your computer and use it in GitHub Desktop.
Function to create animation frames
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
def create_frames(dt, steps, padding, output_dir): | |
fig, ax = create_blank_chart_with_styling((6, 6)) | |
# creation of data describing the trajectory | |
xs, ys, zs = build_lorenz_trajectory(dt, steps) | |
# setting the fixed range of axes | |
ax.set_xlim3d(xs.min() - padding, xs.max() + padding) | |
ax.set_ylim3d(ys.min() - padding, ys.max() + padding) | |
ax.set_zlim3d(zs.min() - padding, zs.max() + padding) | |
for i in range(steps-1): | |
# the colour of the line will change over time | |
ax.plot(xs[i:i+2], ys[i:i+2], zs[i:i+2], color=plt.cm.viridis(1 - i/steps), lw=2) | |
# angle of view on the graph | |
ax.view_init(30, 45 + i) | |
# saving the frame in a file with the appropriate index | |
plt.savefig("./" + output_dir + "/lorenz_{:0>5d}.png".format(i)) | |
plt.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment