diff --git a/examples/user_guide/Linked_Brushing.ipynb b/examples/user_guide/Linked_Brushing.ipynb index c033af3a14..10e38a27ce 100644 --- a/examples/user_guide/Linked_Brushing.ipynb +++ b/examples/user_guide/Linked_Brushing.ipynb @@ -291,7 +291,7 @@ "outputs": [], "source": [ "linked_choropleth.opts(\n", - " hv.opts.Polygons(tools=['hover', 'tap'], xaxis=None, yaxis=None,\n", + " hv.opts.Polygons(tools=['hover', 'tap', 'box_select'], xaxis=None, yaxis=None,\n", " show_grid=False, show_frame=False, width=500, height=500,\n", " color='Unemployment', colorbar=True, line_color='white'),\n", " hv.opts.Histogram(width=500, height=500)\n", @@ -387,27 +387,33 @@ "metadata": {}, "outputs": [], "source": [ - "import pandas as pd, numpy as np, datashader as ds,datashader.transfer_functions as tf\n", + "import datashader as ds\n", "import holoviews.operation.datashader as hd\n", - "from collections import OrderedDict as odict\n", - "num=100000\n", + "\n", + "num = 100000\n", "np.random.seed(1)\n", - "dists = {cat: pd.DataFrame(odict([('x',np.random.normal(x,s,num)), \n", - " ('y',np.random.normal(y,s,num)), \n", - " ('val',np.random.normal(val,1.5,num)), \n", - " ('cat',cat)])) \n", - " for x, y, s, val, cat in \n", - " [( 2, 2, 0.03, 10, \"d1\"), \n", - " ( 2, -2, 0.10, 20, \"d2\"), \n", - " ( -2, -2, 0.50, 30, \"d3\"), \n", - " ( -2, 2, 1.00, 40, \"d4\"), \n", - " ( 0, 0, 3.00, 50, \"d5\")] }\n", - "df = pd.concat(dists,ignore_index=True)\n", - "df[\"cat\"]=df[\"cat\"].astype(\"category\")\n", - "points = hv.Points(df)#.sample(10000))\n", + "\n", + "dists = {\n", + " cat: pd.DataFrame({\n", + " 'x': np.random.normal(x, s, num), \n", + " 'y': np.random.normal(y, s, num), \n", + " 'val': np.random.normal(val, 1.5, num), \n", + " 'cat': cat\n", + " }) for x, y, s, val, cat in \n", + " [( 2, 2, 0.03, 10, \"d1\"), \n", + " ( 2, -2, 0.10, 20, \"d2\"), \n", + " ( -2, -2, 0.50, 30, \"d3\"), \n", + " ( -2, 2, 1.00, 40, \"d4\"), \n", + " ( 0, 0, 3.00, 50, \"d5\")]\n", + "}\n", + "\n", + "points = hv.Points(pd.concat(dists), ['x', 'y'], ['val', 'cat'])\n", "datashaded = hd.datashade(points, aggregator=ds.count_cat('cat'))\n", "spreaded = hd.dynspread(datashaded, threshold=0.50, how='over')\n", - "histogram = points.hist(num_bins=60, adjoin=False).opts(color=((0.1+hv.dim('val')/10).round()).categorize(hv.Cycle('Set1').values))\n", + "\n", + "# Declare dim expression to color by cluster\n", + "dim_expr = ((0.1+hv.dim('val')/10).round()).categorize(hv.Cycle('Set1').values)\n", + "histogram = points.hist(num_bins=60, adjoin=False, normed=False).opts(color=dim_expr)\n", "\n", "link_selections(spreaded + histogram)" ]