%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))
/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
from ipywidgets import StaticInteract, RangeWidget, RadioWidget
def fn(x,a,b):
return a*x+b
def plot(a, b):
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, 11)
ax.plot(x, fn(x,a,b), lw=5, alpha=0.4)
# ax.set_xlim(-50, 50)
# ax.set_ylim(-2.5, 2.5)
return fig
StaticInteract(plot,a=RangeWidget(1., 5., 1.),b=RangeWidget(1., 5., 1.))
/usr/local/lib/python2.7/dist-packages/matplotlib/pyplot.py:423: 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)