Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update a mayavi plot programmatically #1293

Open
armandosano opened this issue Mar 15, 2024 · 0 comments
Open

Update a mayavi plot programmatically #1293

armandosano opened this issue Mar 15, 2024 · 0 comments

Comments

@armandosano
Copy link

Is there an easy solution to force the update of a Mayavi plot, e.g. after its source data is updated?

Using mlab.animate() as suggested in the documentation works but is not suitable for me, since the flow is not under control of the user: replotting occurs at predefined regular time intervals. I would like to be able to replot based on some conditions in my program.

Traits might be a solution, but it seems rather complicated for a simple task, and unclear how updates can be triggered programmatically rather than via user interaction in the GUI dialog window, i.e., one of the issues is to feed into the event loop started by mlab.show().

Here is how I would ideally see this feature (adapted from the example in the doc at the link above):

import numpy as np
from mayavi import mlab
x, y = np.mgrid[0:3:1,0:3:1]
s = mlab.surf(x, y, np.asarray(x*0.1, 'd'))

mlab.show() # <== issue: hangs there until mayavi window is closed to continue execution of the script.

for i in range(10):
    s.mlab_source.scalars = np.asarray(x*0.1*(i+1), 'd')
    s.refresh() # <== or similar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant