Commit 1956c3c8 authored by Matthieu Boileau's avatar Matthieu Boileau
Browse files

Fix slider in ipynb

parent 806ee6e4
......@@ -37,10 +37,11 @@
"%matplotlib inline\n",
"from matplotlib import rcParams\n",
"from matplotlib import pyplot as plt\n",
"from ipywidgets import interact, fixed\n",
"import ipywidgets as widgets\n",
"from ipywidgets import interact, fixed, FloatSlider\n",
"rcParams['figure.figsize'] = (8., 6.) # Enlarge figure\n",
"rcParams['animation.html'] = 'html5' # to render animation in notebook\n",
"# A slider for p\n",
"slider = FloatSlider(min=-1., max=2., step=0.1, value=1.1, continuous_update=False)\n",
"\n",
"from earth_movers import EarthMovers1D, EarthMovers2D"
]
......@@ -58,12 +59,13 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"scrolled": false
},
"outputs": [],
"source": [
"em1D = EarthMovers1D(50)\n",
"interact(em1D.plot_ot, p=widgets.FloatSlider(min=-1., max=2., step=0.1, value=1.1),\n",
" plot_points=fixed(True));"
"interact(em1D.plot_ot, p=slider, plot_points=fixed(True));"
]
},
{
......@@ -81,9 +83,8 @@
"metadata": {},
"outputs": [],
"source": [
"em2D = EarthMovers2D(50)\n",
"interact(em2D.plot_ot, p=widgets.FloatSlider(min=-1., max=2., step=0.1, value=1.1),\n",
" plot_points=fixed(True));"
"em2D = EarthMovers2D(100)\n",
"interact(em2D.plot_ot, p=slider, plot_points=fixed(True));"
]
},
{
......@@ -100,8 +101,7 @@
"outputs": [],
"source": [
"em2D_large = EarthMovers2D(1000)\n",
"interact(em2D_large.plot_ot, p=widgets.FloatSlider(min=-1., max=2., step=0.1, value=1.1),\n",
" plot_points=fixed(False));"
"interact(em2D_large.plot_ot, p=slider, plot_points=fixed(False));"
]
},
{
......@@ -114,7 +114,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"scrolled": false
},
"outputs": [],
"source": [
"em2D_2000 = EarthMovers2D(2000)\n",
......
......@@ -35,10 +35,10 @@
"%matplotlib inline\n",
"from matplotlib import rcParams\n",
"from matplotlib import pyplot as plt\n",
"from ipywidgets import interact\n",
"import ipywidgets as widgets\n",
"from ipywidgets import interact, FloatSlider, RadioButtons\n",
"rcParams['figure.figsize'] = (8., 6.) # Enlarge figure\n",
"rcParams['animation.html'] = 'html5' # to render animation in notebook\n",
"slider = FloatSlider(min=0., max=1., step=0.1, value=0.5, continuous_update=False)\n",
"\n",
"from percolation import PercolationRect, PercolationHex, percolation_vs_p, PercolationRectDual"
]
......@@ -61,7 +61,7 @@
"outputs": [],
"source": [
"percorect = PercolationRect(20, 10)\n",
"interact(percorect.plot, p=widgets.FloatSlider(min=0., max=1., step=0.1, value=0.5));"
"interact(percorect.plot, p=slider);"
]
},
{
......@@ -82,7 +82,7 @@
"outputs": [],
"source": [
"percohex = PercolationHex(5, 5)\n",
"percohex.compute_clusters(0.5)\n",
"percohex.compute_clusters(0.2)\n",
"percohex.plot_clusters(add_cluster_id=True)"
]
},
......@@ -97,7 +97,7 @@
"outputs": [],
"source": [
"percohex15 = PercolationHex(30, 30)\n",
"interact(percohex15.plot, p=widgets.FloatSlider(min=0., max=1., step=0.1, value=0.5));"
"interact(percohex15.plot, p=slider);"
]
},
{
......@@ -136,8 +136,8 @@
"outputs": [],
"source": [
"perco = PercolationRectDual(5)\n",
"interact(perco.plot_graph, p=widgets.FloatSlider(min=0., max=1., step=0.1, value=0.5),\n",
" graph_type=widgets.RadioButtons(options=['initial', 'dual', 'both']));"
"interact(perco.plot_graph, p=slider,\n",
" graph_type=RadioButtons(options=['initial', 'dual', 'both']));"
]
},
{
......
......@@ -40,8 +40,7 @@
"%matplotlib inline\n",
"from matplotlib import rcParams\n",
"from matplotlib import pyplot as plt\n",
"from ipywidgets import interact\n",
"import ipywidgets as widgets\n",
"from ipywidgets import interact, IntSlider\n",
"rcParams['figure.figsize'] = (8., 6.) # Enlarge figure\n",
"rcParams['animation.html'] = 'html5' # to render animation in notebook\n",
"\n",
......@@ -111,7 +110,11 @@
},
"outputs": [],
"source": [
"interact(srw.plot_walk, nstep=widgets.IntSlider(min=100, max=1000, step=100, value=50));"
"def plot_walk(nstep: int):\n",
" srw.Walk2D(nstep).plot()\n",
"\n",
"slider = IntSlider(min=100, max=20000, step=100, value=5000, continuous_update=False)\n",
"interact(plot_walk, nstep=slider);"
]
},
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment