%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
def plot(amplitude, color):
fig, ax = plt.subplots(figsize=(4, 3),
subplot_kw={'axisbg':'#EEEEEE',
'axisbelow':True})
ax.grid(color='w', linewidth=2, linestyle='solid')
x = np.linspace(0, 10, 1000)
ax.plot(x, amplitude * np.sin(x), color=color,
lw=5, alpha=0.4)
ax.set_xlim(0, 10)
ax.set_ylim(-1.1, 1.1)
return fig
from ipywidgets import StaticInteract, RangeWidget, RadioWidget
StaticInteract(plot,
amplitude=RangeWidget(0.1, 1.0, 0.1),
color=RadioWidget(['blue', 'green', 'red']))
/usr/lib/pymodules/python2.7/matplotlib/pyplot.py:412: RuntimeWarning: More than 20 figures have been opened. Figures created through the pyplot interface (`matplotlib.pyplot.figure`) are retained until explicitly closed and may consume too much memory. (To control this warning, see the rcParam `figure.max_num_figures`). max_open_warning, RuntimeWarning)
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
def plot(amplitude1, amplitude2):
fig, ax = plt.subplots(figsize=(4, 3),
subplot_kw={'axisbg':'#EEEEEE',
'axisbelow':True})
ax.grid(color='w', linewidth=2, linestyle='solid')
x = np.linspace(0, 10, 1000)
ax.plot(x, amplitude1 * np.sin(x) + amplitude2*np.sin(x), lw=5, alpha=0.4)
ax.set_xlim(0, 10)
ax.set_ylim(-1.1, 1.1)
return fig
from ipywidgets import StaticInteract, RangeWidget, RadioWidget
StaticInteract(plot,amplitude1=RangeWidget(0.1, 0.3, 0.1),amplitude2=RangeWidget(0.1, 0.3, 0.1))
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
def plot(f1, f2):
fig, ax = plt.subplots(figsize=(4, 3),
subplot_kw={'axisbg':'#EEEEEE',
'axisbelow':True})
ax.grid(color='w', linewidth=2, linestyle='solid')
x = np.linspace(-50, 50, 1000)
ax.plot(x, np.sin(f1*x) + np.sin(f2*x), lw=5, alpha=0.4)
ax.set_xlim(-50, 50)
ax.set_ylim(-2.5, 2.5)
return fig
from ipywidgets import StaticInteract, RangeWidget, RadioWidget
StaticInteract(plot,f1=RangeWidget(1.0, 1.5, 0.1),f2=RangeWidget(1.0, 1.5, 0.1))
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
def fn(y):
return np.sin(y)
def plot(f1, f2):
fig, ax = plt.subplots(figsize=(4, 3),
subplot_kw={'axisbg':'#EEEEEE',
'axisbelow':True})
ax.grid(color='w', linewidth=2, linestyle='solid')
x = np.linspace(-50, 50, 1000)
ax.plot(x, fn(f1*x) + fn(f2*x), lw=5, alpha=0.4)
ax.set_xlim(-50, 50)
ax.set_ylim(-2.5, 2.5)
return fig
from ipywidgets import StaticInteract, RangeWidget, RadioWidget
StaticInteract(plot,f1=RangeWidget(1.0, 1.5, 0.1),f2=RangeWidget(1.0, 1.5, 0.1))
/usr/lib/pymodules/python2.7/matplotlib/pyplot.py:412: RuntimeWarning: More than 20 figures have been opened. Figures created through the pyplot interface (`matplotlib.pyplot.figure`) are retained until explicitly closed and may consume too much memory. (To control this warning, see the rcParam `figure.max_num_figures`). max_open_warning, RuntimeWarning)