I dont know why cannot find widget or abbreviation for argument:'i1'. How to modify?
from ipywidgets import interact from pylab import * from math import * import matplotlib.pyplot as plt import numpy as py n1=0 n2=0 def Snell_law(n1,n2,i1): %matplotlib.inline axis[(-10,10,-10,10)] grid() axhline(color='c',linewidth=3) t=np.arange(0,10,0.1) if 90>=i1>asin(n2/n1)/pi*180: x=sin(i1/180*pi)*t y=cos(i1/180*pi)*t x1=sin(i1/180*pi)*-t y1=cos(i1/180*pi)*t elif 0<i1<=asin(n2/n1)/pi*180: x=sin(i1/180*pi)*t y=cos(i1/180*pi)*t x1=sin(i1/180*pi)*-t y1=sin(i1/180*pi)*t i2=asin(n1/n2*sin(x1))/pi*180 x2=sin(abs(n2)/180*pi)*-t y2=cos(abs(n2)/180*pi)*-t plt.plot(x,y,'-',label="rayon incident") plt.plot(x1,y1,'--',label="rayon refracte") plt.plot(x2,y2,'---',label="rayon reflechi") plt.legend() plt.title("Animation Snell_law") plt.show() interact(Snell_law, i1=(0,90,1) ,n1=(1,3,0.1) ,n2=(1,3,0.1))