diff --git a/doc/Tutorials/Dynamic_Map.ipynb b/doc/Tutorials/Dynamic_Map.ipynb index 9f5fe5a168..0b870cf978 100644 --- a/doc/Tutorials/Dynamic_Map.ipynb +++ b/doc/Tutorials/Dynamic_Map.ipynb @@ -250,7 +250,56 @@ "\n", "* There must be as many positional arguments in the callable signature as key dimensions.\n", "* The argument order in the callable signature must match the order of the declared key dimensions.\n", - "* All key dimensions are defined with a bounded ``range`` or ``values`` parameter (for categorical dimensions)." + "* All key dimensions are defined with a bounded ``range`` or ``values`` parameter (for categorical dimensions).\n", + "\n", + "Here is another example of a bounded ``DynamicMap``:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def shapes(N, radius=0.5): # Positional keyword arguments are fine\n", + " paths = [hv.Path([[(radius*np.sin(a), radius*np.cos(a)) \n", + " for a in np.linspace(-np.pi, np.pi, n+2)]], \n", + " extents=(-1,-1,1,1)) \n", + " for n in range(N,N+3)]\n", + " return hv.Overlay(paths)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "%%opts Path (linewidth=1.5)\n", + "dmap = hv.DynamicMap(shapes, kdims=[hv.Dimension('N', range=(2,20)), hv.Dimension('radius', range=(0.5,1))])\n", + "dmap" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "As you can see, you can return ``Overlays`` from ``DynamicMaps`` and ``DynamicMaps`` can be styled in exactly the same way as ``HoloMaps``. Note that currently, ``Overlay`` objects should be returned from the callable and the ``*`` operator is not yet supported at the ``DynamicMap`` level. " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "%opts Path (linewidth=1.5)" ] }, { @@ -321,7 +370,7 @@ }, "outputs": [], "source": [ - "dmap[{(0,0.01), (0,0.5), (0.5,0.01), (0.5,0.5)}] # Returns a *new* DynamicMap with the sampled keys in it's cache" + "dmap[{(2,0.5), (2,1.0), (3,0.5), (3,1.0)}] # Returns a *new* DynamicMap with the specified keys in it's cache" ] }, { @@ -343,7 +392,7 @@ }, "outputs": [], "source": [ - "dmap[{0,0.5},{0.01,0.5}]" + "dmap[{2,3},{0.5,1.0}]" ] }, { @@ -404,7 +453,7 @@ }, "outputs": [], "source": [ - "sliced = dmap[0.2:0.8, :]\n", + "sliced = dmap[4:8, :]\n", "sliced" ] }, @@ -423,7 +472,7 @@ }, "outputs": [], "source": [ - "sliced[:, 0.05:0.1]" + "sliced[:, 0.8:1.0]" ] }, { @@ -471,8 +520,8 @@ }, "outputs": [], "source": [ - "hv.DynamicMap(sine_image, kdims=[hv.Dimension('phase',values=[0,0.5]),\n", - " hv.Dimension('frequency', values=[0.01,0.5])])" + "hv.DynamicMap(shapes, kdims=[hv.Dimension('N', values=[2,3,4,5]), \n", + " hv.Dimension('radius', values=[0.7,0.8,0.9,1])])\n" ] }, { @@ -497,7 +546,7 @@ }, "outputs": [], "source": [ - "dmap = hv.DynamicMap(sine_image, kdims=['phase', 'frequency'], sampled=True)\n", + "dmap = hv.DynamicMap(shapes, kdims=['N', 'radius'], sampled=True)\n", "dmap" ] }, @@ -516,7 +565,7 @@ }, "outputs": [], "source": [ - "dmap[{0,0.5},{0.01,0.5}]" + "dmap[{2,3},{0.5,1.0}]" ] }, { @@ -534,9 +583,8 @@ }, "outputs": [], "source": [ - "dmap + hv.HoloMap({(p,f):sine_image(p, f) \n", - " for p in [0,0.5,1,1.5] \n", - " for f in [0.5,0.75]}, kdims=['phase', 'frequency'])" + "(dmap + hv.HoloMap({(N,r):shapes(N, r) for N in [3,4,5] \n", + " for r in [0.5,0.75]}, kdims=['N', 'radius']))" ] }, {