2D Graph Animation in Jupyter Notebook
In this blog we will learn how to plot 2D graph animation in jupyter notebook using ipywidgets
Note: This method only works in Jupyter Notebook
- First we are going to import all the important libraries as per our requirements
- We are going to use ipywidgets for our animation works
- We have define a function called theta which have parameter called t . The function will be update with respect to time when we define widgets
- After that we simply write the code of sin graph
- Then we will call widgets.interact to do our animation work min and max are the value upto which theta value will be update
Code :
import numpy as np
import matplotlib.pyplot as plt
import ipywidgets as widgets
def theta(t):
x = np.linspace(0,t,180)
y = np.sin(np.radians(x))
plt.plot(x,y)
widgets.interact(theta , t= widgets.Play(min=0,max =360));
Other Blog : Trignometry Graph Visualisation in Jupyter Notebook
0 Comments
if you are not getting it then ask i am glad to help