Morh's Circle App


In [1]:
import ipywidgets as widgets

In [3]:
%matplotlib notebook
from ipywidgets import *
import numpy as np
import matplotlib.pyplot as plt

r = 1
n = 64
t = np.linspace(0, 2*np.pi, n+1)
x = r*np.cos(t)
y = r*np.sin(t)
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
ax.axis("equal")
ax.grid()
line, = ax.plot(x,y)

def update(r = 1.0, n=0.0, m=0.0):
    line.set_xdata(r*np.cos(t)+n)
    line.set_ydata(r*np.sin(t)+m)
    
    fig.canvas.draw_idle()

interact(update);



In [2]:
a = widgets.FloatText()
b = widgets.FloatSlider(description='sigma x')
c = widgets.FloatSlider(description='sigma y')
d = widgets.FloatSlider(description='shear xy')
display(a,b,c,d)

mylink = widgets.jslink((a, 'value'), (b, 'value'))



In [13]:
%matplotlib notebook
from ipywidgets import *
import numpy as np
import matplotlib.pyplot as plt

x = np.linspace(0, 2 * np.pi)
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
line, = ax.plot(x, np.sin(x))

def update(w = 1.0):
    line.set_ydata(np.sin(w * x))
    fig.canvas.draw_idle()

interact(update);



In [4]:
import numpy as np

In [5]:
%matplotlib inline
r = 1
n = 64
t = np.linspace(0, 2*np.pi, n+1)
x = r*np.cos(t)
y = r*np.sin(t)
plt.axis("equal")
plt.grid()
plt.plot(x,y)
plt.show()



In [14]:
%matplotlib notebook
from ipywidgets import *
import numpy as np
import matplotlib.pyplot as plt

r = 1
n = 64
t = np.linspace(0, 2*np.pi, n+1)
x = r*np.cos(t)
y = r*np.sin(t)
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
ax.axis("equal")
ax.grid()
line, = ax.plot(x,y)

def update(r = 1.0, n=1.0, m=1.0):
    line.set_xdata(r*np.cos(t)+n)
    line.set_ydata(r*np.sin(t)+m)
    
    fig.canvas.draw_idle()

interact(update);



In [ ]: