Skip to content

Instantly share code, notes, and snippets.

@ven-kyoshiro
Created December 21, 2021 05:45
Show Gist options
  • Save ven-kyoshiro/da075c0f41f8e891cbb1d7ba288f0659 to your computer and use it in GitHub Desktop.
Save ven-kyoshiro/da075c0f41f8e891cbb1d7ba288f0659 to your computer and use it in GitHub Desktop.
import matplotlib.pyplot as plt
import matplotlib.animation as animation
import numpy as np
"""
marge two scatter animation
"""
fig = plt.figure()
x_base = np.random.randn(100)
ims = []
for i in range(40):
x = x_base + i/10
y1 = np.sin(x)
c1 = np.random.rand(100)/10
c2 = np.random.rand(100)/10
y2 = np.cos(x)
line =plt.scatter(x,y1,c=c1,s=10,alpha=0.4,cmap="rainbow",zorder=1,label="1")
line2 = plt.scatter(x,y2,c=c2,s=10,alpha=0.4,cmap="Greys",zorder=0,label="2")
plt.clim(0, 1)
ims.append([line,line2])
plt.xlabel("labelkkkkkkk")
plt.hlines(0,0,1)
plt.yticks([0])
plt.legend()
plt.colorbar(label="Frequency[Hz]")
ax = plt.gca()
ax.set_facecolor('black')
ani = animation.ArtistAnimation(fig, ims,interval=100)
ani.save(f'tmp_vis.mp4', writer="ffmpeg")
@ven-kyoshiro
Copy link
Author

tmp_vis.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment