Skip to content

Commit

Permalink
Removed usages of .options in user guide
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Dec 21, 2018
1 parent 32601df commit 1576731
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 45 deletions.
20 changes: 10 additions & 10 deletions examples/user_guide/04-Style_Mapping.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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')"
]
Expand Down Expand Up @@ -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) "
]
},
{
Expand Down Expand Up @@ -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)"
]
},
{
Expand Down Expand Up @@ -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",
")"
]
Expand All @@ -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"
Expand Down Expand Up @@ -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)"
]
},
{
Expand Down Expand Up @@ -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))"
]
},
{
Expand Down Expand Up @@ -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)"
]
},
{
Expand Down
8 changes: 4 additions & 4 deletions examples/user_guide/09-Indexing_and_Selecting_Data.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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)])"
]
},
Expand Down Expand Up @@ -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"
Expand All @@ -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"
]
},
Expand Down Expand Up @@ -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"
]
Expand Down
23 changes: 18 additions & 5 deletions examples/user_guide/14-Large_Data.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
]
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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
}
7 changes: 4 additions & 3 deletions examples/user_guide/16-Dashboards.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
]
},
Expand Down Expand Up @@ -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)"
]
},
{
Expand Down Expand Up @@ -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))"
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions examples/user_guide/Colormaps.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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']])"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion examples/user_guide/Customizing_Plots.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
]
},
{
Expand Down
22 changes: 10 additions & 12 deletions examples/user_guide/Deploying_Bokeh_Apps.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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"
]
},
{
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions examples/user_guide/Linking_Plots.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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']))"
]
},
{
Expand Down Expand Up @@ -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",
Expand Down
7 changes: 3 additions & 4 deletions examples/user_guide/Network_Graphs.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
]
},
{
Expand Down Expand Up @@ -149,7 +149,7 @@
"metadata": {},
"outputs": [],
"source": [
"bezier_graph.options(inspection_policy='edges')"
"bezier_graph.relabel('Edge Inspection').opts(inspection_policy='edges')"
]
},
{
Expand Down Expand Up @@ -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))"
]
Expand Down Expand Up @@ -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')"
Expand Down
2 changes: 1 addition & 1 deletion examples/user_guide/Plotting_with_Bokeh.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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))"
]
},
Expand Down

0 comments on commit 1576731

Please sign in to comment.