enthought / enthought/mayavi

Update a mayavi plot programmatically

Open
#1,293 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
1.4k
Forks
316
Avg merge
7h 44m
Merged PRs (30d)
5

Description

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](https://mayavi.readthedocs.io/en/latest/mlab_animating.html#mlab-animating-data) 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
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.