Categories
SMArt Codes

E1 – Shell Life

#E1
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation

x_data = []
y_data = []

fig, ax = plt.subplots()
ax.set_xlim(-200, 200)
ax.set_ylim(-200,200)
line, = ax.plot(0,0)
r=1.2

def animation_frame(i):
    x_data.append(-r*i*np.cos(i*i)-i*np.cos(i))
    y_data.append(r*i*np.sin(i*i)+i*np.sin(i))

    line.set_xdata(x_data)
    line.set_ydata(y_data)
    line.set_linewidth(0.3)
    return line,


animation = FuncAnimation(fig, func=animation_frame, frames=np.arange(0, 132, 0.001), interval=40, blit=True)


#animation.save('E1.mp4', dpi=400, bitrate=-1, codec="libx264", extra_args=['-pix_fmt','yuv420p'])
plt.show()
print("done")

By Kasimir Gregory

PhD Candidate at the University of Newcastle investigating specific-ion effects.
https://scholar.google.com.au/citations?user=O65PgjUAAAAJ&hl=en&oi=ao

Leave a Reply

Your email address will not be published. Required fields are marked *