Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import matplotlib.pyplot as plt
- from matplotlib import animation
- %matplotlib notebook
- x = np.linspace(-7,7,50)
- y = np.linspace(-7,7,50)
- xx, yy = np.meshgrid(x,y)
- points = np.c_[xx.ravel(),yy.ravel()]
- sizes = abs(np.sin(points[:,0]) + np.sin(points[:,1])) * 14 + 5
- colours = np.log10(abs(points[:,0]/points[:,1]))
- points[:,0] += np.sin(points[:,1])
- fig = plt.figure(figsize=(7,7))
- ax = fig.add_axes([0,0,1,1], frameon=False)
- ax.set_xlim((-5,5))
- ax.set_ylim((-5,5))
- scat = ax.scatter(points[:,0],points[:,1], s=sizes, c=colours, alpha=0.8)
- def update(frame_number):
- new_position = points
- new_position[:,0] += np.sin((np.sin(frame_number/11)*(sizes-6))/7)/20
- new_position[:,1] += np.tan((np.cos(frame_number/9)*(abs(colours)**0.25)*3)/7)/15
- scat.set_offsets(new_position)
- anim = animation.FuncAnimation(fig, update, interval=50, frames=300)
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement