{ "metadata": { "name": "" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "code", "collapsed": false, "input": [ "%matplotlib inline\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "from ipywidgets import StaticInteract, RangeWidget, RadioWidget\n", " \n", "def plot(n):\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, 2*np.pi, 100)\n", " y = np.zeros(len(x))\n", " i = 0\n", " while i < n :\n", " y += (1.0/(2*i+1))*np.sin((2*i+1)*x)\n", " i += 1\n", " \n", " ax.plot(x, y, lw=5, alpha=0.4, label = n)\n", " ax.legend(loc='upper right')\n", " ax.set_xlim(0,2*np.pi)\n", " ax.set_ylim(-1, 1)\n", " return fig\n", "\n", "StaticInteract(plot,n=RangeWidget(1, 15, 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", "
\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", " " ], "metadata": {}, "output_type": "pyout", "prompt_number": 4, "text": [ "" ] } ], "prompt_number": 4 }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] } ], "metadata": {} } ] }