Skip to content

Commit

Permalink
apply suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
maximlt committed Sep 13, 2024
1 parent 0fb801d commit 9708d55
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions doc/reference/xarray/vectorfield.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"If we just try to call `ds.hvplot.vectorfield` this is probably returning `MemoryError`. The alternative is to dynamically downsample the data based on the visible range. This helps manage memory consumption when dealing with large datasets, especially when plotting vector fields."
"If we just try to call `ds.hvplot.vectorfield` this is probably returning `MemoryError`. The alternative is to dynamically downsample the data based on the visible range. This helps manage memory consumption when dealing with large datasets, especially when plotting vector fields. We are going to use HoloViews to create a view (`hv.DynamicMap`) whose content is dynamically updated based on the data range displayed (tracked by the `hv.streams.RangeXY` stream), [find out more about these concepts](https://holoviews.org/user_guide/Custom_Interactivity.html)."
]
},
{
Expand All @@ -159,7 +159,7 @@
"metadata": {},
"outputs": [],
"source": [
"def create_quiver(x_range=None, y_range=None, nmax=10):\n",
"def downsample_quiver(x_range=None, y_range=None, nmax=10):\n",
" \"\"\"\n",
" Creates a HoloViews vector field plot from a dataset, dynamically downsampling \n",
" data based on the visible range to optimize memory usage.\n",
Expand Down Expand Up @@ -203,13 +203,18 @@
" hover=False,\n",
" ).opts(magnitude=\"mag\")\n",
"\n",
" return quiver\n",
"\n",
"\n",
" return quiver"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Create interactive plot components\n",
"range_xy = hv.streams.RangeXY() # Stream to capture range changes\n",
"filtered = hv.DynamicMap(create_quiver, streams=[range_xy]) # Dynamic plot\n",
"range_xy.source = filtered # Link stream to the plot\n",
"filtered = hv.DynamicMap(downsample_quiver, streams=[range_xy]) # Dynamic plot\n",
"filtered # Display the plot"
]
}
Expand Down

0 comments on commit 9708d55

Please sign in to comment.