{ "metadata": { "name": "" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "code", "collapsed": false, "input": [ "from ipywidgets import StaticInteract, RangeWidget, RadioWidget\n", "import matplotlib.pyplot as plt\n", "%matplotlib inline\n", "import numpy as np\n", "\n", "var = 1\n", "\n", "def plot(a):\n", " fig, ax = plt.subplots(figsize=(4, 3),subplot_kw={'axisbg':'#EEEEEE','axisbelow':True})\n", " ax.grid(color='w', linewidth=2, linestyle='solid')\n", " x = np.linspace(-2, 2, 201)\n", " y = np.sinc((x+a)/var)**2 + np.sinc((x-a)/var)**2\n", " ax.plot(x, y, lw=5, alpha=0.4)\n", " return fig\n", "\n", "StaticInteract(plot,a=RangeWidget(0, 2, 0.1))" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stderr", "text": [ "/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`).\n", " max_open_warning, RuntimeWarning)\n" ] }, { "html": [ "\n", " \n", " \n", "