Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f00effa

Browse files
Update linked-brushing.ipynb
1 parent 73d19fc commit f00effa

File tree

1 file changed

+30
-5
lines changed

1 file changed

+30
-5
lines changed

‎3-tech-demos/linked-brushing.ipynb‎

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@
2929
"from holoviews.selection import link_selections\n",
3030
"from holoviews.operation import gridmatrix\n",
3131
"from holoviews.operation.element import histogram\n",
32-
"from holoviews import opts"
32+
"from holoviews import opts\n",
33+
"\n",
34+
"import warnings\n",
35+
"warnings.simplefilter(\"ignore\")"
3336
]
3437
},
3538
{
@@ -67,7 +70,7 @@
6770
"outputs": [],
6871
"source": [
6972
"gdf.loc[:, 'x'], gdf.loc[:, 'y'] = lnglat_to_meters(gdf.geometry.x, gdf.geometry.y)\n",
70-
"df = pd.DataFrame(gdf)"
73+
"df = pd.DataFrame(gdf).head(10000)"
7174
]
7275
},
7376
{
@@ -106,17 +109,39 @@
106109
"source": [
107110
"def selected_bar_plot(x_range, y_range):\n",
108111
" if x_range:\n",
109-
" tmp = df[(df.x>x_range[0])&(df.x<x_range[1])]\n",
112+
" tmp = df[(df.x > x_range[0]) & (df.x < x_range[1]) & (df.y > y_range[0]) & (df.y < y_range[1])]\n",
110113
" else:\n",
111114
" tmp = df\n",
112-
" return tmp.groupby(\"ShipType\").count().hvplot.bar(x=\"ShipType\", y='MMSI', width=400, rot=90)\n",
115+
" counts = tmp.groupby(\"ShipType\").count()\n",
116+
" counts = counts.reset_index()\n",
117+
" n_all = counts.MMSI.sum()\n",
118+
" n_max = counts.MMSI.max()\n",
119+
" return counts.hvplot.bar(title=f\"{n_max} records\", x=\"ShipType\", y='MMSI', width=400, height=400, rot=90, color=\"ShipType\", colormap=\"Category20\", ylim=(0,n_max),)\n",
113120
"\n",
114-
"map_plot = df.hvplot.scatter(x='x', y='y', c=\"ShipType\", width=700, height=300)\n",
121+
"map_plot = df.hvplot.scatter(title=f\"AIS\", x='x', y='y', c=\"ShipType\", width=700, height=400, colormap=\"Category20\")\n",
115122
"rangexy = hv.streams.RangeXY(source=map_plot)\n",
116123
" \n",
124+
"map_plot + hv.DynamicMap(selected_bar_plot, streams=[rangexy])"
125+
]
126+
},
127+
{
128+
"cell_type": "code",
129+
"execution_count": null,
130+
"metadata": {},
131+
"outputs": [],
132+
"source": [
117133
"map_plot << hv.DynamicMap(selected_bar_plot, streams=[rangexy])"
118134
]
119135
},
136+
{
137+
"cell_type": "code",
138+
"execution_count": null,
139+
"metadata": {},
140+
"outputs": [],
141+
"source": [
142+
"map_plot + hv.DynamicMap(selected_bar_plot, streams=[rangexy])"
143+
]
144+
},
120145
{
121146
"cell_type": "markdown",
122147
"metadata": {},

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /