diff --git a/examples/user_guide/04-Style_Mapping.ipynb b/examples/user_guide/04-Style_Mapping.ipynb index 5ee9b5fdad..c8cb178598 100644 --- a/examples/user_guide/04-Style_Mapping.ipynb +++ b/examples/user_guide/04-Style_Mapping.ipynb @@ -334,7 +334,7 @@ "ls = np.linspace(0, 10, 400)\n", "xx, yy = np.meshgrid(ls, ls)\n", "bounds=(-1,-1,1,1) # Coordinate system: (left, bottom, right, top)\n", - "img = hv.Image(np.sin(xx)*np.cos(yy), bounds=bounds).options(colorbar=True, width=400)\n", + "img = hv.Image(np.sin(xx)*np.cos(yy), bounds=bounds).opts(colorbar=True, width=400)\n", "\n", "img.relabel('PiYG').opts(cmap='PiYG') + img.relabel('PiYG_r').opts(cmap='PiYG_r')" ] @@ -377,7 +377,7 @@ "metadata": {}, "outputs": [], "source": [ - "img.relabel('5 color levels').opts(cmap='PiYG', color_levels=5) + img.relabel('11 color levels').options(cmap='PiYG', color_levels=11) " + "img.relabel('5 color levels').opts(cmap='PiYG', color_levels=5) + img.relabel('11 color levels').opts(cmap='PiYG', color_levels=11) " ] }, { @@ -406,7 +406,7 @@ "source": [ "polygons = hv.Polygons([{('x', 'y'): hv.Ellipse(0, 0, (i, i)).array(), 'z': i} for i in range(1, 10)[::-1]], vdims='z')\n", "\n", - "polygons.options(color='z', colorbar=True, width=380)" + "polygons.opts(color='z', colorbar=True, width=380)" ] }, { @@ -484,7 +484,7 @@ " (-88.0, 35.6, 111), (-85.3, 38.6, 96)\n", "]\n", "\n", - "hv.Path([path], vdims='Wind Speed').options(\n", + "hv.Path([path], vdims='Wind Speed').opts(\n", " color='Wind Speed', color_levels=levels, cmap=colors, line_width=8, colorbar=True, width=450\n", ")" ] @@ -510,8 +510,8 @@ "arr = np.sin(xx)*np.cos(yy)\n", "arr[:190, :127] = np.NaN\n", "\n", - "original = hv.Image(arr, bounds=bounds).options(**options)\n", - "colored = original.options(clipping_colors=clipping)\n", + "original = hv.Image(arr, bounds=bounds).opts(**options)\n", + "colored = original.opts(clipping_colors=clipping, clone=True)\n", "clipped = colored.redim.range(z=(0, 0.9))\n", "\n", "original + colored + clipped" @@ -563,7 +563,7 @@ ")\n", "\n", "color_cycle = hv.Cycle(['red', 'green', 'blue'])\n", - "points.relabel('Default Cycle') + points.opts(opts.Points(color=color_cycle), clone=True)" + "points + points.opts(opts.Points(color=color_cycle), clone=True)" ] }, { @@ -629,7 +629,7 @@ "color = hv.Cycle(['#30a2da', '#fc4f30', '#e5ae38'])\n", "markers = hv.Cycle(['x', '^', '+'])\n", "sizes = hv.Cycle([10, 5])\n", - "points.options(opts.Points(line_color=color, marker=markers, size=sizes))" + "points.opts(opts.Points(line_color=color, marker=markers, size=sizes))" ] }, { @@ -667,8 +667,8 @@ "source": [ "ellipses = hv.Overlay([hv.Ellipse(0, 0, s) for s in range(6)])\n", "\n", - "ellipses.relabel('Palette').options(opts.Ellipse(color=hv.Palette('Spectral'), line_width=5)) +\\\n", - "ellipses.relabel('Cycle' ).options(opts.Ellipse(color=hv.Cycle( 'Spectral'), line_width=5))" + "ellipses.relabel('Palette').opts(opts.Ellipse(color=hv.Palette('Spectral'), line_width=5), clone=True) +\\\n", + "ellipses.relabel('Cycle' ).opts(opts.Ellipse(color=hv.Cycle( 'Spectral'), line_width=5), clone=True)" ] }, { diff --git a/examples/user_guide/09-Indexing_and_Selecting_Data.ipynb b/examples/user_guide/09-Indexing_and_Selecting_Data.ipynb index e73c0c85a2..b9990164a0 100644 --- a/examples/user_guide/09-Indexing_and_Selecting_Data.ipynb +++ b/examples/user_guide/09-Indexing_and_Selecting_Data.ipynb @@ -352,7 +352,7 @@ "outputs": [], "source": [ "img_coords = hv.Points(img, extents=extents)\n", - "labeled_img = img * img_coords * hv.Points([img.closest([(4.1,4.3)])]).options(color='r')\n", + "labeled_img = img * img_coords * hv.Points([img.closest([(4.1,4.3)])]).opts(color='r')\n", "img + labeled_img + img.sample([(4.1,4.3)])" ] }, @@ -441,7 +441,7 @@ "hv.output(backend='matplotlib', size=120)\n", "\n", "sample_style = dict(edgecolors='k', alpha=1)\n", - "all_samples = obs_hmap.collapse().to.scatter3d().options(alpha=0.15, xticks=4)\n", + "all_samples = obs_hmap.collapse().to.scatter3d().opts(alpha=0.15, xticks=4)\n", "sampled = obs_hmap.sample((3,3))\n", "subsamples = sampled.to.scatter3d().opts(**sample_style)\n", "all_samples * subsamples + sampled" @@ -461,7 +461,7 @@ "outputs": [], "source": [ "sampled = obs_hmap.sample((3,3), bounds=(2,5,5,10))\n", - "subsamples = sampled.to.scatter3d().opts(xticks=4, **sample_style))\n", + "subsamples = sampled.to.scatter3d().opts(xticks=4, **sample_style)\n", "all_samples * subsamples + sampled" ] }, @@ -491,7 +491,7 @@ " kdims='Observation')\n", "all_samples = curve.collapse().to.points()\n", "sampled = curve.sample([0, 2, 4, 6, 8])\n", - "sample_points = sampled.to.points(extents=extents)\n", + "sample_points = sampled.to.points(extents=extents)\n", "sampling = all_samples * sample_points.opts(color='red')\n", "sampling + sampled" ] diff --git a/examples/user_guide/14-Large_Data.ipynb b/examples/user_guide/14-Large_Data.ipynb index 55e8bd0241..ecdbed6956 100644 --- a/examples/user_guide/14-Large_Data.ipynb +++ b/examples/user_guide/14-Large_Data.ipynb @@ -256,7 +256,7 @@ "\n", "from datashader.colors import Sets1to3 # default datashade() and shade() color cycle\n", "color_key = list(enumerate(Sets1to3[0:num_ks]))\n", - "color_points = hv.NdOverlay({k: hv.Points([0,0], label=str(k)).options(color=v) for k, v in color_key})\n", + "color_points = hv.NdOverlay({k: hv.Points([0,0], label=str(k)).opts(color=v) for k, v in color_key})\n", "\n", "(color_points * gaussspread).opts(width=600)" ] @@ -427,8 +427,8 @@ "g = 0.5*np.sin(0.02*xs**2+0.2*ys**2)+0.5\n", "b = 0.5*np.sin(0.02*xs**2+0.02*ys**2)+0.5\n", "\n", - "opts2 = dict(filled=True, edge_color_index='z')\n", - "tri = hv.TriMesh.from_vertices(hv.Points(np.random.randn(N,3), vdims='z')).options(**opts2)\n", + "opts2 = dict(filled=True, edge_color='z')\n", + "tri = hv.TriMesh.from_vertices(hv.Points(np.random.randn(N,3), vdims='z')).opts(**opts2)\n", "(tri + tri.edgepaths + datashade(tri, aggregator=ds.mean('z')) + datashade(tri.edgepaths)).cols(2)\n", "\n", "shadeable = [elemtype(pts) for elemtype in [hv.Curve, hv.Scatter, hv.Points]]\n", @@ -532,11 +532,24 @@ } ], "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", - "pygments_lexer": "ipython3" + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.6.6" } }, "nbformat": 4, - "nbformat_minor": 1 + "nbformat_minor": 2 } diff --git a/examples/user_guide/16-Dashboards.ipynb b/examples/user_guide/16-Dashboards.ipynb index b10aed8dad..cd3a3e8958 100644 --- a/examples/user_guide/16-Dashboards.ipynb +++ b/examples/user_guide/16-Dashboards.ipynb @@ -43,6 +43,7 @@ "\n", "stock_symbols = ['AAPL', 'IBM', 'FB', 'GOOG', 'MSFT']\n", "dmap = hv.DynamicMap(load_symbol, kdims='Symbol').redim.values(Symbol=stock_symbols)\n", + "\n", "dmap.opts(framewise=True)" ] }, @@ -80,7 +81,7 @@ " def load_symbol(self):\n", " df = pd.DataFrame(getattr(stocks, self.symbol))\n", " df['date'] = df.date.astype('datetime64[ns]')\n", - " return hv.Curve(df, ('date', 'Date'), self.variable).options(framewise=True)" + " return hv.Curve(df, ('date', 'Date'), self.variable).opts(framewise=True)" ] }, { @@ -128,11 +129,11 @@ "smoothed = rolling(stock_dmap, streams=[window])\n", "\n", "# Find outliers\n", - "outliers = rolling_outlier_std(stock_dmap, streams=[window]).options(\n", + "outliers = rolling_outlier_std(stock_dmap, streams=[window]).opts(\n", " hv.opts.Scatter(color='red', marker='triangle')\n", ")\n", "\n", - "pn.Row(explorer.param, (smoothed * outliers).options(width=600))" + "pn.Row(explorer.param, (smoothed * outliers).opts(width=600))" ] }, { diff --git a/examples/user_guide/Colormaps.ipynb b/examples/user_guide/Colormaps.ipynb index f86a3c1811..2a9d5bc3f9 100644 --- a/examples/user_guide/Colormaps.ipynb +++ b/examples/user_guide/Colormaps.ipynb @@ -29,9 +29,9 @@ "ls = np.linspace(0, 10, 400)\n", "x,y = np.meshgrid(ls, ls)\n", "img = hv.Image(np.sin(x)*np.cos(y)+0.1*np.random.rand(400,400), \n", - " bounds=(-20,-20,20,20)).options(colorbar=True, xaxis=None, yaxis=None)\n", + " bounds=(-20,-20,20,20)).opts(colorbar=True, xaxis=None, yaxis=None)\n", "\n", - "hv.Layout([img.options(cmap=c).relabel(c) for c in ['gray','PiYG','flag','Set1']])" + "hv.Layout([img.relabel(c).opts(cmap=c) for c in ['gray','PiYG','flag','Set1']])" ] }, { diff --git a/examples/user_guide/Customizing_Plots.ipynb b/examples/user_guide/Customizing_Plots.ipynb index b1ef542f44..fcf8806cd4 100644 --- a/examples/user_guide/Customizing_Plots.ipynb +++ b/examples/user_guide/Customizing_Plots.ipynb @@ -526,7 +526,7 @@ "def formatter(value):\n", " return str(value) + ' days'\n", "\n", - "curve.relabel('Tick formatters').options(xformatter=formatter, yformatter='$%.2f', width=500)" + "curve.relabel('Tick formatters').opts(xformatter=formatter, yformatter='$%.2f', width=500)" ] }, { diff --git a/examples/user_guide/Deploying_Bokeh_Apps.ipynb b/examples/user_guide/Deploying_Bokeh_Apps.ipynb index 6914244816..fec446381a 100644 --- a/examples/user_guide/Deploying_Bokeh_Apps.ipynb +++ b/examples/user_guide/Deploying_Bokeh_Apps.ipynb @@ -26,10 +26,10 @@ "\n", "HoloViews is an incredibly convenient way of working interactively and exploratively within a notebook or commandline context. However, once you have implemented a polished interactive dashboard or some other complex interactive visualization, you will often want to deploy it outside the notebook to share with others who may not be comfortable with the notebook interface. \n", "\n", - "In the simplest case, to visualize some HoloViews container or element `obj`, you can export it to a standalone HTML file for sharing using the `save` method of the Bokeh renderer:\n", + "In the simplest case, to visualize some HoloViews container or element `obj`, you can export it to a standalone HTML file for sharing using the `save` function of the Bokeh renderer:\n", "\n", "```\n", - "hv.renderer('bokeh').save(obj,'out')\n", + "hv.save(obj, 'out.html')\n", "```\n", "\n", "This command will generate a file `out.html` that you can put on any web server, email directly to colleagues, etc.; it is fully self-contained and does not require any Python server to be installed or running. \n", @@ -68,8 +68,6 @@ "metadata": {}, "outputs": [], "source": [ - "%%opts Points [tools=['box_select', 'lasso_select']]\n", - "\n", "# Declare some points\n", "points = hv.Points(np.random.randn(1000,2 ))\n", "\n", @@ -83,11 +81,11 @@ " label = 'Mean x, y: %.3f, %.3f' % tuple(arr.mean(axis=0))\n", " else:\n", " label = 'No selection'\n", - " return points.clone(arr, label=label).options(color='red')\n", + " return points.clone(arr, label=label).opts(color='red')\n", "\n", "# Combine points and DynamicMap\n", - "layout = points + hv.DynamicMap(selected_info, streams=[selection])\n", - "layout" + "selected_points = hv.DynamicMap(selected_info, streams=[selection])\n", + "points.opts(tools=['box_select', 'lasso_select']) + selected_points" ] }, { @@ -285,7 +283,7 @@ "\n", "renderer = hv.renderer('bokeh')\n", "\n", - "points = hv.Points(np.random.randn(1000,2 )).options(tools=['box_select', 'lasso_select'])\n", + "points = hv.Points(np.random.randn(1000,2 )).opts(tools=['box_select', 'lasso_select'])\n", "selection = hv.streams.Selection1D(source=points)\n", "\n", "def selected_info(index):\n", @@ -294,7 +292,7 @@ " label = 'Mean x, y: %.3f, %.3f' % tuple(arr.mean(axis=0))\n", " else:\n", " label = 'No selection'\n", - " return points.clone(arr, label=label).options(color='red')\n", + " return points.clone(arr, label=label).opts(color='red')\n", "\n", "layout = points + hv.DynamicMap(selected_info, streams=[selection])\n", "\n", @@ -331,7 +329,7 @@ "source": [ "def sine(frequency, phase, amplitude):\n", " xs = np.linspace(0, np.pi*4)\n", - " return hv.Curve((xs, np.sin(frequency*xs+phase)*amplitude)).options(width=800)\n", + " return hv.Curve((xs, np.sin(frequency*xs+phase)*amplitude)).opts(width=800)\n", "\n", "ranges = dict(frequency=(1, 5), phase=(-np.pi, np.pi), amplitude=(-2, 2), y=(-2, 2))\n", "dmap = hv.DynamicMap(sine, kdims=['frequency', 'phase', 'amplitude']).redim.range(**ranges)\n", @@ -492,7 +490,7 @@ "def sine(counter):\n", " phase = counter*0.1%np.pi*2\n", " xs = np.linspace(0, np.pi*4)\n", - " return hv.Curve((xs, np.sin(xs+phase))).options(width=800)\n", + " return hv.Curve((xs, np.sin(xs+phase))).opts(width=800)\n", "\n", "dmap = hv.DynamicMap(sine, streams=[hv.streams.Counter()])\n", "\n", @@ -556,7 +554,7 @@ "# Create the holoviews app again\n", "def sine(phase):\n", " xs = np.linspace(0, np.pi*4)\n", - " return hv.Curve((xs, np.sin(xs+phase))).options(width=800)\n", + " return hv.Curve((xs, np.sin(xs+phase))).opts(width=800)\n", "\n", "stream = hv.streams.Stream.define('Phase', phase=0.)()\n", "dmap = hv.DynamicMap(sine, streams=[stream])\n", diff --git a/examples/user_guide/Linking_Plots.ipynb b/examples/user_guide/Linking_Plots.ipynb index bff2cb5bdd..f67a5bdda3 100644 --- a/examples/user_guide/Linking_Plots.ipynb +++ b/examples/user_guide/Linking_Plots.ipynb @@ -40,7 +40,7 @@ "dlink = DataLink(scatter1, scatter2)\n", "\n", "(scatter1 + scatter2).opts(\n", - " opts.Scatter(tools=['box_select', 'lasso_select']))" + " opts.Scatter(tools=['box_select', 'lasso_select']))" ] }, { @@ -78,8 +78,8 @@ "\n", "data = np.random.randn(1000).cumsum()\n", "\n", - "source = hv.Curve(data).options(width=800, height=125, axiswise=True, default_tools=[])\n", - "target = hv.Curve(data).options(width=800, labelled=['y'], toolbar=None)\n", + "source = hv.Curve(data).opts(width=800, height=125, axiswise=True, default_tools=[])\n", + "target = hv.Curve(data).opts(width=800, labelled=['y'], toolbar=None)\n", "\n", "rtlink = RangeToolLink(source, target)\n", "\n", diff --git a/examples/user_guide/Network_Graphs.ipynb b/examples/user_guide/Network_Graphs.ipynb index 27dd6d5a13..40ef4ad553 100644 --- a/examples/user_guide/Network_Graphs.ipynb +++ b/examples/user_guide/Network_Graphs.ipynb @@ -88,7 +88,7 @@ "metadata": {}, "outputs": [], "source": [ - "simple_graph.options(directed=True, node_size=5, arrowhead_length=0.05)" + "simple_graph.relabel('Directed Graph').opts(directed=True, node_size=5, arrowhead_length=0.05)" ] }, { @@ -149,7 +149,7 @@ "metadata": {}, "outputs": [], "source": [ - "bezier_graph.options(inspection_policy='edges')" + "bezier_graph.relabel('Edge Inspection').opts(inspection_policy='edges')" ] }, { @@ -192,7 +192,7 @@ "nodes = hv.Nodes((x, y, node_indices, node_labels), vdims='Type')\n", "graph = hv.Graph(((source, target, edge_labels), nodes, paths), vdims='Weight')\n", "\n", - "(graph + graph.options(inspection_policy='edges')).opts(\n", + "(graph + graph.opts(inspection_policy='edges', clone=True)).opts(\n", " opts.Graph(node_color='Type', edge_color='Weight', cmap='Set1',\n", " edge_cmap='viridis', edge_line_width=hv.dim('Weight')*10))" ] @@ -358,7 +358,6 @@ "edges_df = pd.read_csv('../assets/fb_edges.csv')\n", "fb_nodes = hv.Nodes(pd.read_csv('../assets/fb_nodes.csv')).sort()\n", "fb_graph = hv.Graph((edges_df, fb_nodes), label='Facebook Circles')\n", - "fb_graph = fb_graph.options()\n", "\n", "fb_graph.opts(cmap=colors, node_size=10, edge_line_width=1,\n", " node_line_color='gray', node_color='circle')" diff --git a/examples/user_guide/Plotting_with_Bokeh.ipynb b/examples/user_guide/Plotting_with_Bokeh.ipynb index 0d62f2d4ee..64e4d3ed2b 100644 --- a/examples/user_guide/Plotting_with_Bokeh.ipynb +++ b/examples/user_guide/Plotting_with_Bokeh.ipynb @@ -541,7 +541,7 @@ "path = hv.Path([])\n", "freehand = hv.streams.FreehandDraw(source=path, num_objects=3)\n", "\n", - "path.options(\n", + "path.opts(\n", " opts.Path(active_tools=['freehand_draw'], height=400, line_width=10, width=400))" ] },