Skip to content

Commit b7c15de

Browse files
authored
Adds kwargs so user can customize vector field estimates (#1036)
* Adds kwargs so user can customize vector field estimates * Does the kwarg organization the way ndpositions does * fixes graphic constructor
1 parent 4c6769e commit b7c15de

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

fastplotlib/widgets/nd_widget/_nd_vectors.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ def __init__(
180180
spatial_func: Callable[[ArrayProtocol], ArrayProtocol] = None,
181181
slider_dim_transforms=None,
182182
name: str = None,
183+
graphic_kwargs: dict = None,
183184
):
184185
"""
185186
``NDGraphic`` subclass for n-dimensional vector rendering
@@ -257,6 +258,11 @@ def __init__(
257258

258259
self._graphic: VectorsGraphic | None = None
259260

261+
if graphic_kwargs is None:
262+
self._graphic_kwargs = dict()
263+
else:
264+
self._graphic_kwargs = graphic_kwargs
265+
260266
# create a graphic
261267
self._create_graphic()
262268

@@ -293,8 +299,10 @@ def _create_graphic(self):
293299
self._subplot.delete_graphic(old_graphic)
294300

295301
# create the new graphic
296-
self._graphic = self._subplot.add_vectors(
297-
positions=data_slice[:, 0], directions=data_slice[:, 1]
302+
self._graphic = VectorsGraphic(
303+
positions=data_slice[:, 0],
304+
directions=data_slice[:, 1],
305+
**self._graphic_kwargs
298306
)
299307

300308
self._subplot.add_graphic(self._graphic)

fastplotlib/widgets/nd_widget/_ndw_subplot.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ def add_nd_vectors(
9494
spatial_func: Callable[[ArrayProtocol], ArrayProtocol] = None,
9595
slider_dim_transforms=None,
9696
name: str = None,
97+
**kwargs
9798
) -> NDVectors:
9899
nd = NDVectors(
99100
self.ndw.indices,
@@ -106,6 +107,7 @@ def add_nd_vectors(
106107
spatial_func=spatial_func,
107108
slider_dim_transforms=slider_dim_transforms,
108109
name=name,
110+
**kwargs
109111
)
110112

111113
self._nd_graphics.append(nd)

0 commit comments

Comments
 (0)