GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — VectorsGraphic by kushalkolar · Pull Request #929 · fastplotlib/fastplotlib

Conversation

@kushalkolar

@kushalkolar kushalkolar commented Oct 21, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

closes #560

Uses instanced meshes to create the 3D vector representations and place them in 3D space.

  • VectorsGraphic graphic which is based on instanced meshes built by merging a cone and cylinder mesh.
    • VectorDirections which manages the positions of the arrows through modifying the translation elements of the transform matrix of the instance buffer
    • VectorDirections which manages the directions of the arrows through modifying the entire transform matrix of the instance buffer
    • supports static immutable single colors for now
    • auto-determines size of the arrows by estimating the density of vectors, or user can provide a specific size or specific shape for the arrows.

Can implement per-vector colors after pygfx/pygfx#1221 later in a future PR.

image

Can do some fun electromagnetism animations with this.

Very simple API:

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 indicate directions in x and y
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()])

vectors = figure[0, 0].add_vectors(
    positions=positions,
    directions=directions,
)

figure.show()

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
kushalkolar added 4 commits October 21, 2025 03:11
@kushalkolar
start vector fields
2828f48
@kushalkolar
basics of vector field works
c439fd9
@kushalkolar
add vector field to api docs
d10d08f
@kushalkolar
update event tables
6858fd6
@kushalkolar
kushalkolar requested a review from clewis7 as a code owner October 21, 2025 09:37
@kushalkolar kushalkolar mentioned this pull request Oct 21, 2025
More features for instancing pygfx/pygfx#1221
Open
@kushalkolar
kushalkolar marked this pull request as draft October 21, 2025 09:38
@kushalkolar
add vector field to subsection_order
178ce12
kushalkolar
kushalkolar commented Oct 21, 2025
View reviewed changes
Comment thread fastplotlib/graphics/vector_field.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

kushalkolar
kushalkolar commented Oct 21, 2025
View reviewed changes
Comment thread fastplotlib/graphics/vector_field.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

kushalkolar
kushalkolar commented Oct 21, 2025
View reviewed changes
Comment thread fastplotlib/graphics/features/_vectors.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

kushalkolar
kushalkolar commented Oct 21, 2025
View reviewed changes
Comment thread fastplotlib/graphics/features/_vectors.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

kushalkolar
kushalkolar commented Oct 21, 2025
View reviewed changes

@kushalkolar kushalkolar left a comment

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

few questions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
almarklein
almarklein reviewed Oct 21, 2025
View reviewed changes
Comment thread fastplotlib/graphics/features/_vectors.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread fastplotlib/graphics/features/_vectors.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread fastplotlib/graphics/features/_vectors.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread fastplotlib/graphics/features/_vectors.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread fastplotlib/graphics/vector_field.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread fastplotlib/graphics/vector_field.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread fastplotlib/graphics/vector_field.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

kushalkolar added 2 commits October 28, 2025 01:54
@kushalkolar
update vector field, almost there
c336b16
@kushalkolar
vector field done and working
f205473
@kushalkolar

kushalkolar commented Oct 28, 2025

Copy link
Copy Markdown
Member Author

Interactions work well:

vectors-2025-10-28_01.52.43.mp4
figure = 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
and pygfx/pygfx#1220

before merging into fastplotlib main

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

kushalkolar added 11 commits October 28, 2025 02:24
@kushalkolar
cleanup
0b98075
@kushalkolar
update docstring
f51a17b
@kushalkolar
update
7df8a9f
@kushalkolar
Merge branch 'main' into vector-field
868ede4
@kushalkolar
black
bec43aa
@kushalkolar
black
6b54967
@kushalkolar
update
d5792bf
@kushalkolar
update .gitignore
3820bfc
@kushalkolar
Merge branch 'main' into vector-field
085b3cb
@kushalkolar
restore stuff in .gitignore
7c56b8c
@kushalkolar
test examples
049f3c5
@kushalkolar
kushalkolar marked this pull request as ready for review October 30, 2025 19:42
@kushalkolar
update min pygfx version
1f29bca
kushalkolar added 2 commits October 30, 2025 17:30
@kushalkolar
ome zarr being annoying
1e8e640
@kushalkolar
remove multi-channel from screenshot tests, only show code in nb
82ee16a
@kushalkolar

kushalkolar commented Oct 30, 2025

Copy link
Copy Markdown
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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@kushalkolar
don't run multi channel example
8e269e0
@github-actions

github-actions Bot commented Oct 30, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

📚 Docs preview built and uploaded! https://www.fastplotlib.org/ver/vector-field

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@kushalkolar
rename to VectorsGraphic since we will use field for something else
bf34866
@kushalkolar kushalkolar changed the title Vector field VectorsGraphic Nov 2, 2025
kushalkolar added 6 commits November 2, 2025 01:25
@kushalkolar
interactive electric field example
b1f23bc
@kushalkolar
update name
3f43786
@kushalkolar
black
1d6ea48
@kushalkolar
update name
8769dce
@kushalkolar
wrong sign, now correct
33e8fae
@kushalkolar
update api docs
b801e7f
clewis7
clewis7 requested changes Nov 2, 2025
View reviewed changes
Comment thread examples/image_volume/image_volume_multi_channel.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread examples/vectors/vectors_swirl.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread pyproject.toml Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread examples/vectors/vectors_interact_electric_charges.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread examples/vectors/vector_field_interact_charges.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread examples/vectors/vector_field_interact_charges.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread examples/vectors/vector_field_interact_charges.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread fastplotlib/graphics/_vectors.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread fastplotlib/graphics/_vectors.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

kushalkolar and others added 7 commits November 2, 2025 19:23
@kushalkolar @clewis7
Apply suggestion from @clewis7
da752af
Co-authored-by: Caitlin Lewis <[email protected]>
@kushalkolar
fix render order and blending, add comment
cfecfa3
@kushalkolar
rename
675ec0b
@kushalkolar
docstrings, comments
7b82f97
@kushalkolar
checks
6ea00e6
@kushalkolar
clarify example
e33f8f7
@kushalkolar
cleanup
e5d0488
clewis7
clewis7 approved these changes Nov 3, 2025
View reviewed changes

@clewis7 clewis7 left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aside from that one example that won't run, everything LGTM

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@kushalkolar
kushalkolar merged commit 61b0c01 into main Nov 4, 2025
@kushalkolar
kushalkolar deleted the vector-field branch November 4, 2025 00:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@almarklein almarklein almarklein left review comments
@clewis7 clewis7 clewis7 approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

VectorsGraphic

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@kushalkolar @almarklein @clewis7
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.