To create an animation in Python, you can use the animation
module of the matplotlib
library. First, you need to create a figure, subplot, and a line plot. Here's an example code that creates a simple animation where the y-coordinate of the line plot is incremented by a random value in every frame:
main.py693 chars32 lines
This code generates a random (x, y)
value pair in the data_gen()
function and appends it to the existing line
plot in the update()
function. The FuncAnimation()
function creates an animation object and the plt.show()
function displays the animation.
gistlibby LogSnag