Skip to content

Commit 73d19fc

Browse files
committed
Update linked-brushing.ipynb
1 parent 0b3645d commit 73d19fc

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

3-tech-demos/linked-brushing.ipynb

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,27 @@
9494
"metadata": {},
9595
"outputs": [],
9696
"source": [
97-
"map_plot + df.groupby(\"ShipType\").count().hvplot.bar(x=\"ShipType\", y='MMSI', width=400, rot=90)"
97+
"bar_plot = df.groupby(\"ShipType\").count().hvplot.bar(x=\"ShipType\", y='MMSI', width=400, rot=90)\n",
98+
"map_plot + bar_plot"
99+
]
100+
},
101+
{
102+
"cell_type": "code",
103+
"execution_count": null,
104+
"metadata": {},
105+
"outputs": [],
106+
"source": [
107+
"def selected_bar_plot(x_range, y_range):\n",
108+
" if x_range:\n",
109+
" tmp = df[(df.x>x_range[0])&(df.x<x_range[1])]\n",
110+
" else:\n",
111+
" tmp = df\n",
112+
" return tmp.groupby(\"ShipType\").count().hvplot.bar(x=\"ShipType\", y='MMSI', width=400, rot=90)\n",
113+
"\n",
114+
"map_plot = df.hvplot.scatter(x='x', y='y', c=\"ShipType\", width=700, height=300)\n",
115+
"rangexy = hv.streams.RangeXY(source=map_plot)\n",
116+
" \n",
117+
"map_plot << hv.DynamicMap(selected_bar_plot, streams=[rangexy])"
98118
]
99119
},
100120
{

0 commit comments

Comments
 (0)