Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
2828f48
start vector fields
kushalkolar Oct 21, 2025
c439fd9
basics of vector field works
kushalkolar Oct 21, 2025
d10d08f
add vector field to api docs
kushalkolar Oct 21, 2025
6858fd6
update event tables
kushalkolar Oct 21, 2025
178ce12
add vector field to subsection_order
kushalkolar Oct 21, 2025
c336b16
update vector field, almost there
kushalkolar Oct 28, 2025
f205473
vector field done and working
kushalkolar Oct 28, 2025
0b98075
cleanup
kushalkolar Oct 28, 2025
f51a17b
update docstring
kushalkolar Oct 28, 2025
7df8a9f
update
kushalkolar Oct 30, 2025
868ede4
Merge branch 'main' into vector-field
kushalkolar Oct 30, 2025
bec43aa
black
kushalkolar Oct 30, 2025
6b54967
black
kushalkolar Oct 30, 2025
d5792bf
update
kushalkolar Oct 30, 2025
3820bfc
update .gitignore
kushalkolar Oct 30, 2025
085b3cb
Merge branch 'main' into vector-field
kushalkolar Oct 30, 2025
7c56b8c
restore stuff in .gitignore
kushalkolar Oct 30, 2025
049f3c5
test examples
kushalkolar Oct 30, 2025
1f29bca
update min pygfx version
kushalkolar Oct 30, 2025
1e8e640
ome zarr being annoying
kushalkolar Oct 30, 2025
82ee16a
remove multi-channel from screenshot tests, only show code in nb
kushalkolar Oct 30, 2025
8e269e0
don't run multi channel example
kushalkolar Oct 30, 2025
bf34866
rename to VectorsGraphic since we will use field for something else
kushalkolar Nov 2, 2025
b1f23bc
interactive electric field example
kushalkolar Nov 2, 2025
3f43786
update name
kushalkolar Nov 2, 2025
1d6ea48
black
kushalkolar Nov 2, 2025
8769dce
update name
kushalkolar Nov 2, 2025
33e8fae
wrong sign, now correct
kushalkolar Nov 2, 2025
b801e7f
update api docs
kushalkolar Nov 2, 2025
da752af
Apply suggestion from @clewis7
kushalkolar Nov 3, 2025
cfecfa3
fix render order and blending, add comment
kushalkolar Nov 3, 2025
675ec0b
rename
kushalkolar Nov 3, 2025
7b82f97
docstrings, comments
kushalkolar Nov 3, 2025
6ea00e6
checks
kushalkolar Nov 3, 2025
e33f8f7
clarify example
kushalkolar Nov 3, 2025
e5d0488
cleanup
kushalkolar Nov 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions docs/source/api/graphic_features/VectorDirections.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
.. _api.VectorDirections:

VectorDirections
****************

================
VectorDirections
================
.. currentmodule:: fastplotlib.graphics.features

Constructor
~~~~~~~~~~~
.. autosummary::
:toctree: VectorDirections_api

VectorDirections

Properties
~~~~~~~~~~
.. autosummary::
:toctree: VectorDirections_api

VectorDirections.value

Methods
~~~~~~~
.. autosummary::
:toctree: VectorDirections_api

VectorDirections.add_event_handler
VectorDirections.block_events
VectorDirections.clear_event_handlers
VectorDirections.remove_event_handler
VectorDirections.set_value

35 changes: 35 additions & 0 deletions docs/source/api/graphic_features/VectorPositions.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
.. _api.VectorPositions:

VectorPositions
***************

===============
VectorPositions
===============
.. currentmodule:: fastplotlib.graphics.features

Constructor
~~~~~~~~~~~
.. autosummary::
:toctree: VectorPositions_api

VectorPositions

Properties
~~~~~~~~~~
.. autosummary::
:toctree: VectorPositions_api

VectorPositions.value

Methods
~~~~~~~
.. autosummary::
:toctree: VectorPositions_api

VectorPositions.add_event_handler
VectorPositions.block_events
VectorPositions.clear_event_handlers
VectorPositions.remove_event_handler
VectorPositions.set_value

2 changes: 2 additions & 0 deletions docs/source/api/graphic_features/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ Graphic Features
VolumeIsoEmissive
VolumeIsoShininess
VolumeSlicePlane
VectorPositions
VectorDirections
TextData
FontSize
TextFaceColor
Expand Down
49 changes: 49 additions & 0 deletions docs/source/api/graphics/VectorField.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
.. _api.VectorField:

VectorField
***********

===========
VectorField
===========
.. currentmodule:: fastplotlib

Constructor
~~~~~~~~~~~
.. autosummary::
:toctree: VectorField_api

VectorField

Properties
~~~~~~~~~~
.. autosummary::
:toctree: VectorField_api

VectorField.alpha
VectorField.alpha_mode
VectorField.axes
VectorField.block_events
VectorField.deleted
VectorField.directions
VectorField.event_handlers
VectorField.name
VectorField.offset
VectorField.positions
VectorField.right_click_menu
VectorField.rotation
VectorField.supported_events
VectorField.visible
VectorField.world_object

Methods
~~~~~~~
.. autosummary::
:toctree: VectorField_api

VectorField.add_axes
VectorField.add_event_handler
VectorField.clear_event_handlers
VectorField.remove_event_handler
VectorField.rotate

1 change: 1 addition & 0 deletions docs/source/api/graphics/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Graphics
ScatterGraphic
ImageGraphic
ImageVolumeGraphic
VectorField
TextGraphic
LineCollection
LineStack
1 change: 1 addition & 0 deletions docs/source/api/layouts/subplot.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Methods
Subplot.add_line_stack
Subplot.add_scatter
Subplot.add_text
Subplot.add_vector_field
Subplot.auto_scale
Subplot.center_graphic
Subplot.center_scene
Expand Down
1 change: 1 addition & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"../../examples/line",
"../../examples/line_collection",
"../../examples/scatter",
"../../examples/vector_field",
"../../examples/text",
"../../examples/events",
"../../examples/selection_tools",
Expand Down
102 changes: 102 additions & 0 deletions docs/source/user_guide/event_tables.rst
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,108 @@ deleted
| value | bool | True when graphic was deleted |
+----------+------+-------------------------------+

VectorField
-----------

positions
^^^^^^^^^

**event info dict**

+----------+------------+----------------------+
| dict key | type | description |
+==========+============+======================+
| value | np.ndarray | new vector positions |
+----------+------------+----------------------+

directions
^^^^^^^^^^

**event info dict**

+----------+------------+-----------------------+
| dict key | type | description |
+==========+============+=======================+
| value | np.ndarray | new vector directions |
+----------+------------+-----------------------+

name
^^^^

**event info dict**

+----------+------+--------------------+
| dict key | type | description |
+==========+======+====================+
| value | str | user provided name |
+----------+------+--------------------+

offset
^^^^^^

**event info dict**

+----------+---------------------------------+----------------------+
| dict key | type | description |
+==========+=================================+======================+
| value | np.ndarray[float, float, float] | new offset (x, y, z) |
+----------+---------------------------------+----------------------+

rotation
^^^^^^^^

**event info dict**

+----------+----------------------------------------+-------------------------+
| dict key | type | description |
+==========+========================================+=========================+
| value | np.ndarray[float, float, float, float] | new rotation quaternion |
+----------+----------------------------------------+-------------------------+

alpha
^^^^^

**event info dict**

+----------+-------+-----------------+
| dict key | type | description |
+==========+=======+=================+
| value | float | new alpha value |
+----------+-------+-----------------+

alpha_mode
^^^^^^^^^^

**event info dict**

+----------+------+----------------+
| dict key | type | description |
+==========+======+================+
| value | str | new alpha mode |
+----------+------+----------------+

visible
^^^^^^^

**event info dict**

+----------+------+---------------------+
| dict key | type | description |
+==========+======+=====================+
| value | bool | new visibility bool |
+----------+------+---------------------+

deleted
^^^^^^^

**event info dict**

+----------+------+-------------------------------+
| dict key | type | description |
+==========+======+===============================+
| value | bool | True when graphic was deleted |
+----------+------+-------------------------------+

TextGraphic
-----------

Expand Down
2 changes: 2 additions & 0 deletions examples/vector_field/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Vector Field Examples
=====================
45 changes: 45 additions & 0 deletions examples/vector_field/vector_field_simple.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
"""
Simple Vector Field
===================

Simple vector field example. Similar to matplotlib quiver.

"""

# test_example = false
# sphinx_gallery_pygfx_docs = 'screenshot'

import numpy as np
import fastplotlib as fpl

figure = fpl.Figure(size=(700, 700))

start, stop, step = 0, 2 * np.pi, 0.2

# get uniform x, y positions
x, y = np.meshgrid(np.arange(start, stop, step), np.arange(start, stop, step))

# vectors, u and v are x and y components indication directions
u = np.cos(x)
v = np.sin(y)

# positions of each vector as [n_points, 2] array
positions = np.column_stack([x.ravel(), y.ravel()])
# directions of each vector as a [n_points, 2] array
directions = np.column_stack([u.ravel(), v.ravel()])


vector_field = figure[0, 0].add_vector_field(
positions=positions,
directions=directions,
spacing=step,
size_scaling_factor=5.0,
)

figure.show()

# NOTE: fpl.loop.run() should not be used for interactive sessions
# See the "JupyterLab and IPython" section in the user guide
if __name__ == "__main__":
print(__doc__)
fpl.loop.run()
49 changes: 49 additions & 0 deletions examples/vector_field/vector_field_swirl.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
"""
Swirling vector field
=====================

Example showing a swirling vector field. Similar to matplotlib quiver.

"""

# test_example = false
# sphinx_gallery_pygfx_docs = 'screenshot'

import numpy as np
import fastplotlib as fpl

figure = fpl.Figure(cameras="3d", controller_types="orbit", size=(700, 700))

start, stop, step = -1, 1, 0.3

# Make the grid
x, y, z = np.meshgrid(
np.arange(start, stop, step),
np.arange(start, stop, step),
np.arange(start, stop, step),
)

# Make the direction data for the arrows
u = np.sin(np.pi * x) * np.cos(np.pi * y) * np.cos(np.pi * z)
v = -np.cos(np.pi * x) * np.sin(np.pi * y) * np.cos(np.pi * z)
w = np.sqrt(2.0 / 3.0) * np.cos(np.pi * x) * np.cos(np.pi * y) * np.sin(np.pi * z)

positions = np.column_stack([x.ravel(), y.ravel(), z.ravel()])
directions = np.column_stack([u.ravel(), v.ravel(), w.ravel()])


vector_field = figure[0, 0].add_vector_field(
positions=positions,
directions=directions,
spacing=step,
size_scaling_factor=2.0,
)

figure.show()


# NOTE: fpl.loop.run() should not be used for interactive sessions
# See the "JupyterLab and IPython" section in the user guide
if __name__ == "__main__":
print(__doc__)
fpl.loop.run()
2 changes: 2 additions & 0 deletions fastplotlib/graphics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from .scatter import ScatterGraphic
from .image import ImageGraphic
from .image_volume import ImageVolumeGraphic
from .vector_field import VectorField
from .text import TextGraphic
from .line_collection import LineCollection, LineStack

Expand All @@ -13,6 +14,7 @@
"ScatterGraphic",
"ImageGraphic",
"ImageVolumeGraphic",
"VectorField",
"TextGraphic",
"LineCollection",
"LineStack",
Expand Down
Loading