{ "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", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", " a: \n", "
\n", " " ], "metadata": {}, "output_type": "pyout", "prompt_number": 1, "text": [ "" ] } ], "prompt_number": 1 }, { "cell_type": "code", "collapsed": false, "input": [ "from ipywidgets import StaticInteract, RangeWidget, RadioWidget\n", "\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "%matplotlib inline\n", "\n", "var = 5\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", " image = np.zeros([10,10])\n", " for i in xrange(len(image)):\n", " for j in xrange(len(image)):\n", " 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)\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", " ax.imshow(image)\n", " return fig\n", "\n", "StaticInteract(plot,a=RangeWidget(1, 5, 1))" ], "language": "python", "metadata": {}, "outputs": [ { "html": [ "\n", " \n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", " a: \n", "
\n", " " ], "metadata": {}, "output_type": "pyout", "prompt_number": 5, "text": [ "" ] } ], "prompt_number": 5 }, { "cell_type": "code", "collapsed": false, "input": [ "from ipywidgets import StaticInteract, RangeWidget, RadioWidget\n", "\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "%matplotlib inline\n", "\n", "var = 5\n", "\n", "def plot(a,b):\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", " image = np.zeros([10,10])\n", " for i in xrange(len(image)):\n", " for j in xrange(len(image)):\n", " 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)\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", " ax.imshow(image)\n", " return fig\n", "\n", "StaticInteract(plot,a=RangeWidget(0.5, 2.5, 0.5),b=RangeWidget(0.5, 2.5, 0.5))" ], "language": "python", "metadata": {}, "outputs": [ { "html": [ "\n", " \n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", "
\n", " \n", " a: \n", "
\n", "b: \n", "
\n", " " ], "metadata": {}, "output_type": "pyout", "prompt_number": 6, "text": [ "" ] } ], "prompt_number": 6 }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] } ], "metadata": {} } ] }