Skip to content

Commit 77bb3a0

Browse files
authored
chore: Example notebook updates (#1023)
Closes #1018, closes #964
1 parent 343fc84 commit 77bb3a0

File tree

6 files changed

+277
-15
lines changed

6 files changed

+277
-15
lines changed

assets/kontur-h3.jpg

666 KB
Loading

examples/clicked-point.ipynb

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": 1,
5+
"execution_count": null,
66
"id": "3371497b",
77
"metadata": {
88
"jupyter": {
@@ -49,18 +49,26 @@
4949
{
5050
"cell_type": "code",
5151
"execution_count": null,
52-
"id": "f986a64e-269f-4966-93b0-cfa5bf1ba882",
52+
"id": "87de8097-4bb9-4180-a3ca-c82c826c38d6",
5353
"metadata": {},
5454
"outputs": [],
5555
"source": [
5656
"from typing import Tuple\n",
5757
"\n",
5858
"import ipywidgets as widgets\n",
5959
"\n",
60-
"from lonboard import Map\n",
61-
"\n",
60+
"from lonboard import Map"
61+
]
62+
},
63+
{
64+
"cell_type": "code",
65+
"execution_count": null,
66+
"id": "f986a64e-269f-4966-93b0-cfa5bf1ba882",
67+
"metadata": {},
68+
"outputs": [],
69+
"source": [
6270
"## Create a Lonboard map and two widgets to display the coordinate\n",
63-
"m = Map(layers=[])\n",
71+
"m = Map(layers=[], view_state={\"zoom\": 1.5}, height=600)\n",
6472
"clicked_x_display = widgets.FloatText(description=\"last clicked x:\")\n",
6573
"clicked_y_display = widgets.FloatText(description=\"last clicked y:\")\n",
6674
"\n",
@@ -82,6 +90,14 @@
8290
" ],\n",
8391
")"
8492
]
93+
},
94+
{
95+
"cell_type": "code",
96+
"execution_count": null,
97+
"id": "05a0e681-899e-4a89-bf86-db55cdbef608",
98+
"metadata": {},
99+
"outputs": [],
100+
"source": []
85101
}
86102
],
87103
"metadata": {

examples/data-filter-extension.ipynb

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@
9393
"import shapely\n",
9494
"from ipywidgets import FloatRangeSlider, jsdlink\n",
9595
"from palettable.colorbrewer.diverging import BrBG_10\n",
96+
"from sidecar import Sidecar\n",
9697
"\n",
9798
"from lonboard import Map, ScatterplotLayer\n",
9899
"from lonboard.colormap import apply_continuous_cmap\n",
@@ -228,6 +229,15 @@
228229
"Next we create a `ScatterplotLayer` with our desired attributes. Keep in mind that you must pass the `DataFilterExtension` instance to the `extensions` parameter in order to activate its functionality on the layer.\n"
229230
]
230231
},
232+
{
233+
"cell_type": "code",
234+
"execution_count": null,
235+
"metadata": {},
236+
"outputs": [],
237+
"source": [
238+
"sidecar = Sidecar(anchor=\"split-right\")"
239+
]
240+
},
231241
{
232242
"cell_type": "code",
233243
"execution_count": null,
@@ -245,7 +255,8 @@
245255
" radius_min_pixels=0.1,\n",
246256
")\n",
247257
"m = Map(layer)\n",
248-
"m"
258+
"with sidecar:\n",
259+
" display(m)"
249260
]
250261
},
251262
{
@@ -285,6 +296,10 @@
285296
" description=\"Latency: \",\n",
286297
")\n",
287298
"multi_slider = MultiRangeSlider([download_slider, upload_slider, latency_slider])\n",
299+
"\n",
300+
"# Important: call jsdlink to link the widgets\n",
301+
"jsdlink((multi_slider, \"value\"), (layer, \"filter_range\"))\n",
302+
"\n",
288303
"multi_slider"
289304
]
290305
},
@@ -300,9 +315,7 @@
300315
"execution_count": null,
301316
"metadata": {},
302317
"outputs": [],
303-
"source": [
304-
"_ = jsdlink((multi_slider, \"value\"), (layer, \"filter_range\"))"
305-
]
318+
"source": []
306319
},
307320
{
308321
"cell_type": "code",

examples/duckdb.ipynb

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
"source": [
7979
"import duckdb\n",
8080
"\n",
81-
"from lonboard import Map, ScatterplotLayer"
81+
"from lonboard import HeatmapLayer, Map"
8282
]
8383
},
8484
{
@@ -149,7 +149,9 @@
149149
"cell_type": "code",
150150
"execution_count": null,
151151
"id": "732bbfd3-b3da-4a38-a539-7a96200b5533",
152-
"metadata": {},
152+
"metadata": {
153+
"scrolled": true
154+
},
153155
"outputs": [],
154156
"source": [
155157
"con.table(\"rides\")"
@@ -170,7 +172,7 @@
170172
"metadata": {},
171173
"outputs": [],
172174
"source": [
173-
"layer = ScatterplotLayer.from_duckdb(con.table(\"rides\"), con)"
175+
"layer = HeatmapLayer.from_duckdb(con.table(\"rides\"), con)"
174176
]
175177
},
176178
{
@@ -180,7 +182,7 @@
180182
"metadata": {},
181183
"outputs": [],
182184
"source": [
183-
"m = Map(layer)\n",
185+
"m = Map(layer, height=700)\n",
184186
"m"
185187
]
186188
},
@@ -218,7 +220,7 @@
218220
"```\n",
219221
"\n",
220222
"Note that the heatmap around airports such as LaGuardia is now darker. There are fewer total rides dropping off at the airport, but each one is expensive!\n",
221-
"-->"
223+
"-->\n"
222224
]
223225
}
224226
],

examples/internet-speeds.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@
210210
"metadata": {},
211211
"outputs": [],
212212
"source": [
213-
"sidecar = Sidecar()"
213+
"sidecar = Sidecar(anchor=\"split-right\")"
214214
]
215215
},
216216
{

examples/kontur_pop.ipynb

Lines changed: 231 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)