In [1]:
from ipywidgets import StaticInteract, RangeWidget, RadioWidget
import matplotlib.pyplot as plt
%matplotlib inline
import numpy as np

var = 1

def plot(a):
    fig, ax = plt.subplots(figsize=(4, 3),subplot_kw={'axisbg':'#EEEEEE','axisbelow':True})
    ax.grid(color='w', linewidth=2, linestyle='solid')
    x = np.linspace(-2, 2, 201)
    y = np.sinc((x+a)/var)**2 + np.sinc((x-a)/var)**2
    ax.plot(x, y, lw=5, alpha=0.4)
    return fig

StaticInteract(plot,a=RangeWidget(0, 2, 0.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)

Out[1]:
a:
In [5]:
from ipywidgets import StaticInteract, RangeWidget, RadioWidget

import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline

var = 5

def plot(a):
    fig, ax = plt.subplots(figsize=(4, 3),subplot_kw={'axisbg':'#EEEEEE','axisbelow':True})
    #ax.grid(color='w', linewidth=2, linestyle='solid')
    #x = np.linspace(-2, 2, 201)
    image = np.zeros([10,10])
    for i in xrange(len(image)):
        for j in xrange(len(image)):
            image[i,j] = (np.sinc((i-4.5-a)/var)**2)*(np.sinc((j-4.5)/var)**2) + (np.sinc((i-4.5+a)/var)**2)*(np.sinc((j-4.5)/var)**2)
#    y = np.sinc((x+a)/var)**2 + np.sinc((x-a)/var)**2
#    ax.plot(x, y, lw=5, alpha=0.4)
    ax.imshow(image)
    return fig

StaticInteract(plot,a=RangeWidget(1, 5, 1))
Out[5]:
a:
In [6]:
from ipywidgets import StaticInteract, RangeWidget, RadioWidget

import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline

var = 5

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(-2, 2, 201)
    image = np.zeros([10,10])
    for i in xrange(len(image)):
        for j in xrange(len(image)):
            image[i,j] = (np.sinc((i-4.5-a)/var)**2)*(np.sinc((j-4.5-b)/var)**2) + (np.sinc((i-4.5+a)/var)**2)*(np.sinc((j-4.5+b)/var)**2)
#    y = np.sinc((x+a)/var)**2 + np.sinc((x-a)/var)**2
#    ax.plot(x, y, lw=5, alpha=0.4)
    ax.imshow(image)
    return fig

StaticInteract(plot,a=RangeWidget(0.5, 2.5, 0.5),b=RangeWidget(0.5, 2.5, 0.5))
Out[6]:
a:
b:
In []: