2D Graph Animation in Jupyter Notebook

 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
  1. First we are going to import all the important libraries as per our requirements
  2. We are going to use ipywidgets for our animation works
  3. 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
  4. After that we simply write the code of sin graph
  5. 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));




Next : 3D Graph animation in Jupyter Notebook

Post a Comment

0 Comments