Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e910e14

Browse files
authored
add jupyter-sidecar as a dependency, update simple notebook (#300)
* add jupyter-sidecar as a dependency, update simple notebook * Update setup.py * add sidecar for plots * sidecar updates * add sidecar to gridplot * add close method to image widget, add sidecar to image widget * fix notebook errors * fix linear region selector * add vbox as kwarg for additional ipywidgets when showing plot and gridplot * fix notebooks
1 parent 0f5655c commit e910e14

File tree

8 files changed

+383
-147
lines changed

8 files changed

+383
-147
lines changed

examples/notebooks/gridplot_simple.ipynb

Lines changed: 67 additions & 52 deletions
Large diffs are not rendered by default.

examples/notebooks/linear_region_selector.ipynb

Lines changed: 21 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "markdown",
5-
"id": "40bf515f-7ca3-4f16-8ec9-31076e8d4bde",
5+
"id": "1db50ec4-8754-4421-9f5e-6ba8ca6b81e3",
66
"metadata": {},
77
"source": [
88
"# `LinearRegionSelector` with single lines"
@@ -11,10 +11,8 @@
1111
{
1212
"cell_type": "code",
1313
"execution_count": null,
14-
"id": "41f4e1d0-9ae9-4e59-9883-d9339d985afe",
15-
"metadata": {
16-
"tags": []
17-
},
14+
"id": "b7bbfeb4-1ad0-47db-9a82-3d3f642a1f63",
15+
"metadata": {},
1816
"outputs": [],
1917
"source": [
2018
"import fastplotlib as fpl\n",
@@ -83,32 +81,12 @@
8381
"ls_x.selection.add_event_handler(set_zoom_x)\n",
8482
"ls_y.selection.add_event_handler(set_zoom_y)\n",
8583
"\n",
86-
"# make some ipywidget sliders too\n",
87-
"# these are not necessary, it's just to show how they can be connected\n",
88-
"x_range_slider = IntRangeSlider(\n",
89-
" value=ls_x.selection(),\n",
90-
" min=ls_x.limits[0],\n",
91-
" max=ls_x.limits[1],\n",
92-
" description=\"x\"\n",
93-
")\n",
94-
"\n",
95-
"y_range_slider = FloatRangeSlider(\n",
96-
" value=ls_y.selection(),\n",
97-
" min=ls_y.limits[0],\n",
98-
" max=ls_y.limits[1],\n",
99-
" description=\"x\"\n",
100-
")\n",
101-
"\n",
102-
"# connect the region selector to the ipywidget slider\n",
103-
"ls_x.add_ipywidget_handler(x_range_slider, step=5)\n",
104-
"ls_y.add_ipywidget_handler(y_range_slider, step=0.1)\n",
105-
"\n",
106-
"VBox([gp.show(), x_range_slider, y_range_slider])"
84+
"gp.show()"
10785
]
10886
},
10987
{
11088
"cell_type": "markdown",
111-
"id": "66b1c599-42c0-4223-b33e-37c1ef077204",
89+
"id": "0bad4a35-f860-4f85-9061-920154ab682b",
11290
"metadata": {},
11391
"source": [
11492
"### On the x-axis we have a 1-1 mapping from the data that we have passed and the line geometry positions. So the `bounds` min max corresponds directly to the data indices."
@@ -117,10 +95,8 @@
11795
{
11896
"cell_type": "code",
11997
"execution_count": null,
120-
"id": "8b26a37d-aa1d-478e-ad77-99f68a2b7d0c",
121-
"metadata": {
122-
"tags": []
123-
},
98+
"id": "2c96a3ff-c2e7-4683-8097-8491e97dd6d3",
99+
"metadata": {},
124100
"outputs": [],
125101
"source": [
126102
"ls_x.selection()"
@@ -129,18 +105,16 @@
129105
{
130106
"cell_type": "code",
131107
"execution_count": null,
132-
"id": "c2be060c-8f87-4b5c-8262-619768f6e6af",
133-
"metadata": {
134-
"tags": []
135-
},
108+
"id": "3ec71e3f-291c-43c6-a954-0a082ba5981c",
109+
"metadata": {},
136110
"outputs": [],
137111
"source": [
138112
"ls_x.get_selected_indices()"
139113
]
140114
},
141115
{
142116
"cell_type": "markdown",
143-
"id": "d1bef432-d764-4841-bd6d-9b9e4c86ff62",
117+
"id": "1588a89e-1da4-4ada-92e2-7437ba942065",
144118
"metadata": {},
145119
"source": [
146120
"### However, for the y-axis line we have passed a 2D array where we've used a linspace, so there is not a 1-1 mapping from the data to the line geometry positions. Use `get_selected_indices()` to get the indices of the data bounded by the current selection. In addition the position of the Graphic is not `(0, 0)`. You must use `get_selected_indices()` whenever you want the indices of the selected data."
@@ -149,10 +123,8 @@
149123
{
150124
"cell_type": "code",
151125
"execution_count": null,
152-
"id": "c370d6d7-d92a-4680-8bf0-2f9d541028be",
153-
"metadata": {
154-
"tags": []
155-
},
126+
"id": "18e10277-6d5d-42fe-8715-1733efabefa0",
127+
"metadata": {},
156128
"outputs": [],
157129
"source": [
158130
"ls_y.selection()"
@@ -161,10 +133,8 @@
161133
{
162134
"cell_type": "code",
163135
"execution_count": null,
164-
"id": "cdf351e1-63a2-4f5a-8199-8ac3f70909c1",
165-
"metadata": {
166-
"tags": []
167-
},
136+
"id": "8e9c42b9-60d2-4544-96c5-c8c6832b79e3",
137+
"metadata": {},
168138
"outputs": [],
169139
"source": [
170140
"ls_y.get_selected_indices()"
@@ -173,10 +143,8 @@
173143
{
174144
"cell_type": "code",
175145
"execution_count": null,
176-
"id": "6fd608ad-9732-4f50-9d43-8630603c86d0",
177-
"metadata": {
178-
"tags": []
179-
},
146+
"id": "a9583d2e-ec52-405c-a875-f3fec5e3aa16",
147+
"metadata": {},
180148
"outputs": [],
181149
"source": [
182150
"import fastplotlib as fpl\n",
@@ -224,7 +192,7 @@
224192
},
225193
{
226194
"cell_type": "markdown",
227-
"id": "63acd2b6-958e-458d-bf01-903037644cfe",
195+
"id": "0fa051b5-d6bc-4e4e-8f12-44f638a00c88",
228196
"metadata": {},
229197
"source": [
230198
"# Large line stack with selector"
@@ -233,10 +201,8 @@
233201
{
234202
"cell_type": "code",
235203
"execution_count": null,
236-
"id": "20e53223-6ccd-4145-bf67-32eb409d3b0a",
237-
"metadata": {
238-
"tags": []
239-
},
204+
"id": "d5ffb678-c989-49ee-85a9-4fd7822f033c",
205+
"metadata": {},
240206
"outputs": [],
241207
"source": [
242208
"import fastplotlib as fpl\n",
@@ -279,7 +245,7 @@
279245
{
280246
"cell_type": "code",
281247
"execution_count": null,
282-
"id": "80e276ba-23b3-43d0-9e0c-86acab79ac67",
248+
"id": "cbcd6309-fb47-4941-9fd1-2b091feb3ae7",
283249
"metadata": {},
284250
"outputs": [],
285251
"source": []
@@ -301,7 +267,7 @@
301267
"name": "python",
302268
"nbconvert_exporter": "python",
303269
"pygments_lexer": "ipython3",
304-
"version": "3.11.4"
270+
"version": "3.11.3"
305271
}
306272
},
307273
"nbformat": 4,

examples/notebooks/linear_selector.ipynb

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "markdown",
5-
"id": "e0354810-f942-4e4a-b4b9-bb8c083a314e",
5+
"id": "a06e1fd9-47df-42a3-a76c-19e23d7b89fd",
66
"metadata": {},
77
"source": [
88
"## `LinearSelector`, draggable selector that can optionally associated with an ipywidget."
@@ -11,10 +11,8 @@
1111
{
1212
"cell_type": "code",
1313
"execution_count": null,
14-
"id": "d79bb7e0-90af-4459-8dcb-a7a21a89ef64",
15-
"metadata": {
16-
"tags": []
17-
},
14+
"id": "eb95ba19-14b5-4bf4-93d9-05182fa500cb",
15+
"metadata": {},
1816
"outputs": [],
1917
"source": [
2018
"import fastplotlib as fpl\n",
@@ -59,21 +57,30 @@
5957
"selector3.add_ipywidget_handler(ipywidget_slider3, step=0.1)\n",
6058
"\n",
6159
"plot.auto_scale()\n",
62-
"plot.show()\n",
63-
"VBox([plot.show(), ipywidget_slider, ipywidget_slider2, ipywidget_slider3])"
60+
"plot.show(vbox=[ipywidget_slider])"
61+
]
62+
},
63+
{
64+
"cell_type": "code",
65+
"execution_count": null,
66+
"id": "7ab9f141-f92f-4c4c-808b-97dafd64ca25",
67+
"metadata": {},
68+
"outputs": [],
69+
"source": [
70+
"selector.step = 0.1"
6471
]
6572
},
6673
{
6774
"cell_type": "markdown",
68-
"id": "2c49cdc2-0555-410c-ae2e-da36c3bf3bf0",
75+
"id": "3b0f448f-bbe4-4b87-98e3-093f561c216c",
6976
"metadata": {},
7077
"source": [
7178
"### Drag linear selectors with the mouse, hold \"Shift\" to synchronize movement of all the selectors"
7279
]
7380
},
7481
{
7582
"cell_type": "markdown",
76-
"id": "69057edd-7e23-41e7-a284-ac55df1df5d9",
83+
"id": "c6f041b7-8779-46f1-8454-13cec66f53fd",
7784
"metadata": {},
7885
"source": [
7986
"## Also works for line collections"
@@ -82,10 +89,8 @@
8289
{
8390
"cell_type": "code",
8491
"execution_count": null,
85-
"id": "1a3b98bd-7139-48d9-bd70-66c500cd260d",
86-
"metadata": {
87-
"tags": []
88-
},
92+
"id": "e36da217-f82a-4dfa-9556-1f4a2c7c4f1c",
93+
"metadata": {},
8994
"outputs": [],
9095
"source": [
9196
"sines = [sine] * 10\n",
@@ -109,7 +114,7 @@
109114
{
110115
"cell_type": "code",
111116
"execution_count": null,
112-
"id": "b6c2d9d6-ffe0-484c-a550-cafb44fa8465",
117+
"id": "71ae4fca-f644-4d4f-8f32-f9d069bbc2f1",
113118
"metadata": {},
114119
"outputs": [],
115120
"source": []
@@ -131,7 +136,7 @@
131136
"name": "python",
132137
"nbconvert_exporter": "python",
133138
"pygments_lexer": "ipython3",
134-
"version": "3.11.4"
139+
"version": "3.11.3"
135140
}
136141
},
137142
"nbformat": 4,

0 commit comments

Comments
 (0)