pyvista-support
pyvista-support copied to clipboard
Plotting without Graphical Back-End
Dear pyvista-folks,
I am thinking about adding a postprocessing step to my calculations on an HPC-cluster, using pyvista.
Is it somehow possible to save plots (png/svg) without a graphical back-end?
For example on matplotlib I use the AGG
back-end.
The following code still opens a window for rendering and I need a way to circumvent this.
import pyvista as pv
mesh = pv.Sphere()
mesh.plot(screenshot='test.png', offscreen=True)
pyvista: 0.28.1
vtk: 8.1.2
Cheers, Markus
Just ran into this issue a moment ago. The issue is that VTK needs to start some sort of render window with the vanilla VTK wheel or conda package. If you want to, you can always use the EGL wheels at Release 0.27, but more often than not, just starting a xvfb
virtual buffer works. Use:
import pyvista as pv
pv.start_xvfb()
You may have to install some additional packages, but it's the easiest way of setting up a virtual framebuffer.
I may be mistaken, but in pyvista 0.28.1
I do not see a pv.start_xvfb()
function. Is this specific to 0.27
?
Sorry, should have looked at your version. We just added that in pyvista==0.29.0
.