{ "metadata": { "language_info": { "codemirror_mode": { "name": "python", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8" }, "kernelspec": { "name": "python", "display_name": "Pyolite", "language": "python" } }, "nbformat_minor": 4, "nbformat": 4, "cells": [ { "cell_type": "code", "source": "import micropip", "metadata": { "trusted": true }, "execution_count": 1, "outputs": [] }, { "cell_type": "code", "source": "await micropip.install(\"ipywidgets\")", "metadata": { "trusted": true }, "execution_count": 2, "outputs": [] }, { "cell_type": "code", "source": "import ipywidgets", "metadata": { "trusted": true }, "execution_count": 3, "outputs": [] }, { "cell_type": "code", "source": "import matplotlib.pyplot as plt\nimport numpy as np", "metadata": { "trusted": true }, "execution_count": 4, "outputs": [] }, { "cell_type": "code", "source": "def plot(amplitude, phase, phase2, showSecondFunction):\n x = np.arange(0, 6.28, 0.1)\n y1 = np.sin(amplitude*x+phase)\n plt.plot(x,y1)\n if showSecondFunction:\n y2 = np.sin(amplitude*x+phase2)\n plt.plot(x,y2)\n plt.show()", "metadata": { "trusted": true }, "execution_count": 19, "outputs": [] }, { "cell_type": "code", "source": "w = ipywidgets.interactive(plot, amplitude=(0.5, 2.0, 0.1), phase=(0, 10, 0.1), phase2=(0, 10, 0.1), showSecondFunction=True)", "metadata": { "trusted": true }, "execution_count": 20, "outputs": [] }, { "cell_type": "code", "source": "display(w)", "metadata": { "trusted": true }, "execution_count": 24, "outputs": [ { "output_type": "display_data", "data": { "text/plain": "interactive(children=(FloatSlider(value=1.2000000000000002, description='amplitude', max=2.0, min=0.5), FloatS…", "application/vnd.jupyter.widget-view+json": { "version_major": 2, "version_minor": 0, "model_id": "17129264c86b4e4497bf96a63bc20eec" } }, "metadata": {} } ] }, { "cell_type": "code", "source": "", "metadata": {}, "execution_count": null, "outputs": [] } ] }