I am trying to create some scientific visualisations using Python
. I use the vedo
library. The plot is not getting cleared and the window is not closing. Please help me diagnose this issue.
I have a set of vtk
files in sequential order and I am trying to create an animation. This is my code:
from vedo import *
import os
vtk_files = [file for file in os.listdir() if file.endswith('.vtk')]
vtk_files.sort()
# Create a Plotter instance
plotter = Plotter()
for i in vtk_files:
print(i)
mesh = load(i,unpack=True, force=True)
plotter += mesh
plotter.show()
plotter.clear()
plotter.close()
While going through the loop, a plot window pops up showing the first vtk file and then it freezes. The plot is not getting cleared and the window is not closing. That means the plotter.clear()
and plotter.close()
commands are not working. When I manually close the plot window the code jumps to the next vtk
file, but it doesn't show the plot as the plot window is already closed. I have the same problem with another visualisation package. Is it something with plotting module (Pyqt
or any widget) which these libraries use? Please help.
I have checked the vtk
and vedo
documentation but I can't find what's wrong. I have gone through a lot of questions on stack overflow and github but I still can't find anything.
You are closing the plotter inside the loop.. Consider these options:
Another option:
will visualise your meshes one by one. Note that objects can also be removed by name e.g.:
mesh.name = "jack"
thenplotter.remove("jack")
will remove it.