Skip to content

Commit

Permalink
improve the sections in the notebook and add RangeSliceWidget to api …
Browse files Browse the repository at this point in the history
…reference
  • Loading branch information
nvaytet committed Apr 19, 2024
1 parent ed312e6 commit f747a1e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/api-reference/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
widgets.Box
widgets.Checkboxes
widgets.HBar
widgets.RangeSliceWidget
widgets.SliceWidget
widgets.VBar
Expand Down
19 changes: 16 additions & 3 deletions docs/gallery/scatter3d-with-slider.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
"id": "f99ea04f-3b3b-49df-b4a2-99aa9bd8090a",
"metadata": {},
"source": [
"## Generate data on a curved panel\n",
"\n",
"We first generate some data that represents events detected on a cylindrical detector panel,\n",
"as a function of time."
]
Expand Down Expand Up @@ -74,6 +76,8 @@
"id": "604b3530-76e0-4fb0-88b3-a731ffb5a162",
"metadata": {},
"source": [
"## A slider selecting a single data slice\n",
"\n",
"We then construct our interface with a slider,\n",
"a node that slices our data at the index of the slider,\n",
"and a `scatter3dfigure`."
Expand All @@ -100,6 +104,16 @@
"pp.widgets.Box([fig, slider])"
]
},
{
"cell_type": "markdown",
"id": "caaa6846-e5b4-4179-9b48-bfb15692dde4",
"metadata": {},
"source": [
"## A slider slicing out a range\n",
"\n",
"It is also possible to use a `RangeSliceWidget` to create a slider with two handles that selects a data range instead of slicing using a single index:"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -111,9 +125,9 @@
"slider = pw.RangeSliceWidget(da, dims=['time'])\n",
"slider_node = pp.widget_node(slider)\n",
"\n",
"# Sum over the selected range of time dimension\n",
"slice_node = pw.slice_dims(data_array=da, slices=slider_node)\n",
"\n",
"# Sum over the selected range of time dimension\n",
"sum_slices = pp.Node(sc.sum, slice_node, dim='time')\n",
"\n",
"fig = pp.scatter3dfigure(sum_slices, pixel_size=0.3)\n",
Expand Down Expand Up @@ -150,8 +164,7 @@
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.8"
"pygments_lexer": "ipython3"
}
},
"nbformat": 4,
Expand Down

0 comments on commit f747a1e

Please sign in to comment.