Comments (10)
Hi @vianamp
thanks for your interest!
Actually the show()
command should be inside the loop. Check out for example this:
from vtkplotter import *
import numpy as np
vp = Plotter(interactive=False)
coo = np.random.rand(32*12).reshape(32,12)
for i in range(len(coo)):
u = coo[i,3:6]
v = coo[i,6:9]
q = coo[i,9:12]
ell = Ellipsoid(pos=(2.5*coo[i,0], 2.5*coo[i,1], 2.5*coo[i,2]),
axis1=u, axis2=v, axis3=q)
scals = [i] * ell.N()
ell.pointColors(scals, vmin=0, vmax=31)
vp += ell
vp.show()
interactive()
Let me know if you need more help. Also, you can find more examples of animations in example/simulations directory which may fit your need.
from vedo.
Yes.. the jupyter functionality is still experimental and at the moment is not working well with loops.
It' s on my to-do list..
If you need to work in notebooks you still have the option of setting:
from vtkplotter import *
embedWindow(False)
then the normal vtk rendering window will pop up.
from vedo.
Thanks for quick reply. What if I need only one timepoint to be shown at the time? And also to keep the bounding box fixed at the largest size that fits all the objects?
from vedo.
Also, I got this error when I tried to run your code on a jupyter notebook:
AttributeError Traceback (most recent call last)
<ipython-input-12-4b069e1c07cd> in <module>()
13 vp.show()
14
---> 15 interactive()
~/anaconda3/envs/qcb/lib/python3.6/site-packages/vtkplotter/plotter.py in interactive()
259 if settings.plotter_instance:
260 if hasattr(settings.plotter_instance, 'interactor'):
--> 261 settings.plotter_instance.interactor.Start()
262 return settings.plotter_instance
263
AttributeError: 'NoneType' object has no attribute 'Start'
from vedo.
There are 2 ways of doing it:
- either you create an invisible box that contains the object that you want to create afterwards or
- render the scene once outside the loop with e.g.
vp.show(world, ell, resetcam=False)
from vtkplotter import *
import numpy as np
vp = Plotter(interactive=False)
coo = np.random.rand(32*12).reshape(32,12)
world = Box([1,1,1], 5,5,5).wireframe().alpha(0) ##########
for i in range(len(coo)):
u = coo[i,3:6]
v = coo[i,6:9]
q = coo[i,9:12]
ell = Ellipsoid(pos=(2.5*coo[i,0], 2.5*coo[i,1], 2.5*coo[i,2]),
axis1=u, axis2=v, axis3=q)
scals = [i] * ell.N()
ell.pointColors(scals, vmin=0, vmax=31)
vp.show(world, ell)
interactive()
About the jupyter thing indeed this a current limitation (or ... bug) due to how the K3D backend works...
One needs to collect the object returned by show()
and then just expose it outside the loop...
from vedo.
I see what you mean. My final code looks like this:
np.random.seed(1234)
n = 8
vp = Plotter(interactive=False)
coo = np.random.rand(n*12).reshape(n,12)
world = Box([1,1,1], 5,5,5).wireframe().alpha(0)
for i in range(n):
u = coo[i,3:6]
v = coo[i,6:9]
q = coo[i,9:12]
ell = Ellipsoid(pos=(2.5*coo[i,0], 2.5*coo[i,1], 2.5*coo[i,2]), axis1=u, axis2=v, axis3=q)
scals = [i] * ell.N()
ell.pointColors(scals, vmin=0, vmax=n)
vp += ell
plt = vp.show(world, ell, resetcam=False)
plt
However, I don't actually see the animation. Only the last timepoint is shown.
from vedo.
How to fix the viewing angle to the first frame. The object moves a little bit in the following gif.
Thanks~
@marcomusy
from vedo.
you can either add an invisible box:
vp += Box((1,1,1), length=5, width=5, height=5).wireframe().alpha(0)
or avoid resetting the camera later with
vp.show(resetcam=False)
in the ex. above, as the the object are added randomly, the first solution is probably the best.
from vedo.
Hi, marcomusy~
How to add a description for each frame like: "frame: {}/{}.format(current, all)"
?
If I set by txt = Text(...)
with background, it seems to get slower and slower, if I use vp.clear(txt)
, there will be flashes.
from vedo.
@LogWell
thanks for spotting the problem, I'll investigate that.
from vedo.
Related Issues (20)
- Term colors changed after printing a DataFrame with a Mesh HOT 2
- How to join two boundaries with different number of vertices
- Bug: Extra faces created in cut_with_plane with incorrect pointdata HOT 6
- Feature Request: Determine where genus are present in mesh HOT 2
- Bug: Thumbnail slices part of mesh HOT 1
- Bug: mesh.thumbnail hangs in docker container HOT 3
- Compute outward normals for pointdata HOT 2
- Exit without error reporting, when no NVIDIA driver is available HOT 3
- Return type annotations for vedo functions HOT 4
- jupyter notebook kernal keeps crashing after calling plt.show() HOT 1
- Window gives No Responde afte use of rotate() with big angle HOT 1
- typing.Self is not compatible with python3.10 HOT 1
- How to move object or rotate the object interactively ? HOT 14
- Reusing intersection points HOT 2
- Find intersection for parallel, flat Meshes HOT 7
- Exit viewer on control + c in terminal HOT 2
- Rounded Line generates warning, displays incorrectly HOT 2
- Suggestion: Returning intersection points too when return_cell_id is true HOT 4
- how to open multiple panels on one window ? HOT 5
- Feature: Determine visible cells from point HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vedo.