In [1]:
%matplotlib inline
from IPython.html.widgets import interact, fixed, interactive
import matplotlib.pyplot as plt
import numpy as np
In [2]:
def plot_sin(n, phi, title='Trigonometric Functions'):
x = np.linspace(-2*3.14, 2*3.14, 1000)
y1 = np.sin(n*(x-phi))
y2 = np.cos(n*(x-phi))
plt.plot(x, y1, label='Sin(nx)')
plt.plot(x, y2, label='Cos(nx)')
plt.title(title)
plt.legend()
plt.axis([0, 2*3.14, -1.1, 1.1])
In [3]:
interact(plot_sin, n=(0, 10), phi=(0, 2*3.14, 0.1))
In [4]:
@interact(x=True, y={'netherlands': 1, 'india': 10})
def g(x, y):
print(x, y)