animation matplotlib

Solutions on MaxInterview for animation matplotlib by the best coders in the world

showing results for - "animation matplotlib"
Emma
10 Jul 2019
1import matplotlib.pyplot as plt
2from matplotlib import cm
3import numpy as np
4from celluloid import Camera
5
6numpoints = 10
7points = np.random.random((2, numpoints))
8colors = cm.rainbow(np.linspace(0, 1, numpoints))
9camera = Camera(plt.figure())
10for _ in range(100):
11    points += 0.1 * (np.random.random((2, numpoints)) - .5)
12    plt.scatter(*points, c=colors, s=100)
13    camera.snap()
14anim = camera.animate(blit=True)
15anim.save('scatter.mp4')
16
Martín
12 Jul 2019
1import numpy as np
2import matplotlib.pyplot as plt
3from matplotlib.animation import FuncAnimation
4
5fig, ax = plt.subplots()
6xdata, ydata = [], []
7ln, = plt.plot([], [], 'ro')
8
9def init():
10    ax.set_xlim(0, 2*np.pi)
11    ax.set_ylim(-1, 1)
12    return ln,
13
14def update(frame):
15    xdata.append(frame)
16    ydata.append(np.sin(frame))
17    ln.set_data(xdata, ydata)
18    return ln,
19
20ani = FuncAnimation(fig, update, frames=np.linspace(0, 2*np.pi, 128),
21                    init_func=init, blit=True)
22plt.show()
23
queries leading to this page
matplotlib animation tutorialanimation funcanimantion matplotlibanimate matplotlibmatplotlib animation plotpython matplotlib animate graphanimation in matplotlibanimations in matplotlibmatplotlib animation functionanimate matplotlib in a whilehow to make an animation in matplotlibhow to animate using matplotlib in pythonanimate 3d plot matplotlibmatplotlib animationanimate matplotlib librarypip install matplotlib animationcreate animation in matplotlibpython plot animationanimate plot pytohnhow to save an animation in python matplotlibmatplotlib animation jupyteranimate plot pythonmatplotlib animation plot pythonmatplotlib create animationfunction animation matplotlibmatplotlib animation examplesmatplotlib animation examplepython matplotlib animation examplehow to make animations with matplotlibmatplotlib animationanimation using matplotlibanimation with matplotlibanimate matplotlib sinepyplot animate plotget data from animation matplotlib pythonmatplotlib animate through datmatplotlib animation funcanimationmatplotlib animation graphanimation matplotlibmatplotlib python code animationmatplotlib animation examplematplotlib animate plotanimate plots matplotlibmatplotlib animate plot pythonmatplot lib animationmatplotlib animation installmatplotlib animation examplesmatplotlib animateanimate plt plot in pythonfrom matplotlib import animationhow to create animations in python with matplotlibmatplotlib animationsanimation python matplotlibanimation matplotlib