{ "metadata": { "name": "" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "http://jakevdp.github.io/blog/2013/12/05/static-interactive-widgets/ - reference" ] }, { "cell_type": "code", "collapsed": false, "input": [ "%matplotlib inline\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "\n", "def plot(amplitude, color):\n", " fig, ax = plt.subplots(figsize=(4, 3),\n", " subplot_kw={'axisbg':'#EEEEEE',\n", " 'axisbelow':True})\n", " ax.grid(color='w', linewidth=2, linestyle='solid')\n", " x = np.linspace(0, 10, 1000)\n", " ax.plot(x, amplitude * np.sin(x), color=color,\n", " lw=5, alpha=0.4)\n", " ax.set_xlim(0, 10)\n", " ax.set_ylim(-1.1, 1.1)\n", " return fig" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 1 }, { "cell_type": "code", "collapsed": false, "input": [ "from ipywidgets import StaticInteract, RangeWidget, RadioWidget\n", "\n", "StaticInteract(plot,\n", " amplitude=RangeWidget(0.1, 1.0, 0.1),\n", " color=RadioWidget(['blue', 'green', 'red']))" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stderr", "text": [ "/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`).\n", " max_open_warning, RuntimeWarning)\n" ] }, { "html": [ "\n", " \n", " \n", "