Merged
Conversation
kushalkolar
commented
Oct 21, 2025
kushalkolar
commented
Oct 21, 2025
kushalkolar
commented
Oct 21, 2025
kushalkolar
commented
Oct 21, 2025
almarklein
reviewed
Oct 21, 2025
Member
Author
|
Interactions work well: vectors-2025-10-28_01.52.43.mp4figure = fpl.Figure(size=(700, 700))
start, stop, step = 0, 2 * np.pi, 0.4
# 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,
)
def update(change):
val = change["new"]
start, stop, step = 0, 2 * np.pi, 0.4
start += val
stop += val
# 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)
directions = np.column_stack([u.ravel(), v.ravel()])
vector_field.directions = directions
slider = FloatSlider(value=0, min=-5, max=5, step=0.01)
slider.observe(update, "value")
VBox([figure.show(), slider])Need to wait for pygfx/pylinalg#107 before merging into fastplotlib main |
Member
Author
|
The recursion error with the ome-zarr file makes no sense, going to get rid of it from tests and only show the code in the docs until they fix whatever is up. |
|
📚 Docs preview built and uploaded! https://www.fastplotlib.org/ver/vector-field |
clewis7
requested changes
Nov 2, 2025
Co-authored-by: Caitlin Lewis <caitlin9165@gmail.com>
clewis7
approved these changes
Nov 3, 2025
Member
clewis7
left a comment
There was a problem hiding this comment.
Aside from that one example that won't run, everything LGTM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #560
Uses instanced meshes to create the 3D vector representations and place them in 3D space.
VectorsGraphicgraphic which is based on instanced meshes built by merging a cone and cylinder mesh.VectorDirectionswhich manages the positions of the arrows through modifying the translation elements of the transform matrix of the instance bufferVectorDirectionswhich manages the directions of the arrows through modifying the entire transform matrix of the instance bufferCan implement per-vector colors after pygfx/pygfx#1221 later in a future PR.
Can do some fun electromagnetism animations with this.
Very simple API: