Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
Update notebook.
  • Loading branch information
fm75 committed Sep 17, 2019
1 parent d50f7f7 commit 824be96
Showing 1 changed file with 97 additions and 0 deletions.
97 changes: 97 additions & 0 deletions index.ipynb
@@ -0,0 +1,97 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"from ipywidgets import interact\n",
"from ipywidgets.widgets import IntSlider, Dropdown\n",
"plt.ion()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Ipywidgets"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"data = np.logspace(0, 2, 100)\n",
"data = np.tile(data, [100, 1])\n",
"data += np.random.randn(100, 100) * 50\n",
"data += np.linspace(0, 1000, 100)[:, np.newaxis]"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "14bcec67909a43598eaca5a05a8f5e30",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"interactive(children=(IntSlider(value=0, description='ii', max=99), Dropdown(description='cmap', options=('coo…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"cmaps = ['coolwarm', 'viridis', 'magma']\n",
"def plot_data(ii, cmap):\n",
" fig, ax = plt.subplots()\n",
" cmap = plt.get_cmap(cmap)\n",
" color = cmap(ii / 100.)\n",
" ax.plot(data[ii], color=color)\n",
" ax.set_ylim([0, 1000])\n",
" plt.show()\n",
" \n",
"p = interact(plot_data, ii=IntSlider(0, 0, 99), cmap=Dropdown(options=cmaps))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

0 comments on commit 824be96

Please sign in to comment.