November 2018
Beginner to intermediate
214 pages
5h 2m
English
Let's begin by importing the necessary functions and use the Matplotlib Notebook interactive backend. We will also import the FuncAnimation method from Matplotlib.animation.
Start by making the standard basic sine plot. We have also added a function that changes the Y data by moving it over to the first argument. We will now use the func.animation method. As we call the func.animation method with the figure and our update method as the two arguments, we get a nice animation of the sine wave:
# Basic FuncAnimationnums = np.arange(0,10,0.1)sin, = plt.plot(nums, np.sin(nums))def update(i): sin.set_ydata(np.sin(nums+i))FuncAnimation(plt.gcf(), update)
Following is the output of the ...
Read now
Unlock full access